Share on Google+Share on Google+

praveena
blank space in input field
1 Answer(s)      7 years ago
Posted in : Java Beginners
I retrieved the fields from my mysql table...If the field contains null value i want to display a blank space in input field(text box)..but i am displaying null how to overcome this..


u r help is highly appreciated.

Ads

View Answers

April 6, 2010 at 1:24 PM


Hi Friend,

In the following code, we have retrieved null value in third textbox.

import java.sql.*;
import java.awt.*;
import javax.swing.*;

class DisplayData{
JLabel lab1,lab2,lab3;
JTextField text1,text2,text3;

JPanel p;
JFrame f;
DisplayData(){
lab1=new JLabel("Name");
lab2=new JLabel("Address");
lab3=new JLabel("Contact No");
text1= new JTextField(20);
text2= new JTextField(20);
text3= new JTextField(20);
p=new JPanel(new GridLayout(3,2));
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register";, "root", "root");
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("Select name, address, contactNo from person where id='2'");
String name="",address="";
int contact=0;
while(rs.next()){
name=rs.getString("name");
address=rs.getString("address");
contact=rs.getInt("contactNo");
}
text1.setText(name);
text2.setText(address);
if(contact==0){
text3.setText(" ");
}
}
catch(Exception e){}

f=new JFrame();
p.add(lab1);
p.add(text1);
p.add(lab2);
p.add(text2);
p.add(lab3);
p.add(text3);
f.add(p);
f.pack();
f.setVisible(true);
}
public static void main(String[] args) {
DisplayData data=new DisplayData();
}
}

Thanks









Related Tutorials/Questions & Answers:
blank space in input field - Java Beginners
blank space in input field  I retrieved the fields from my mysql table...If the field contains null value i want to display a blank space in input field(text box)..but i am displaying null how to overcome this.. u r help
Validaton(Checking Blank space) - Spring
Validaton(Checking Blank space)  Hi i am using java springs .I am having problem in doing validation. I am just checking blank space. This is my controller. I named it salescontroller. package controller; import
Advertisements
jsf text field not blank
jsf text field not blank  text field not clear in jsf onclick of reset button in my application initial value not deleted   Hello Friend, Post your code. Thanks
MySQL Blank Field
MySQL Blank Field This example illustrates how to find Blank field by the MySQL Query. In the table 'example' two t_count fields are blank and we find both field which has some value by query 'select * from example where t_count
iPhone Input Field, iPhone Input Field Tutorial
iPhone Input Field Generally, input fields are used to take input from the users.  In iPhone application we can use Text Field to take the input. ... input field according to your requirement. Creating an Application.. 1
insertin form data into databse and blank all form field when click on submit button
insertin form data into databse and blank all form field when click on submit... database when click on submit button and blank all form field after inserting...;<td><input type="text" name="name"></td></tr> <tr>
UItextfield blank
UItextfield blank  Hi, How I can check if UITextfield is blank... be used to validate the user input in iPhone and iPad applications. if([loginID.text...] initWithTitle:@"Field Error" message:@"Please enter Login ID
Can not input value into text field which use sx:datetimepicker
Can not input value into text field which use sx:datetimepicker  I am using lib: struts2-dojo-plugin-2.2.3.1.jar. My source is below: I input value from calendar, it runs normal. But i input value from keyboard by hands
Show text field & check input using jQuery
Show text field & check input using jQuery In this tutorial, we will discuss about how to display 'text field' by a button click & check... how to display 'text field' by a button click & check input using
Can not input value into text field which use sx:datetimepicker
Can not input value into text field which use sx:datetimepicker  I am..." cssStyle="font-size:13.5px" accesskey="true" />"); I input value from calendar, it runs normal. But i input value from keyboard by hands and then i move focus
How to collect Java input field value display into Jtable?
How to collect Java input field value display into Jtable?  <p>We would like to know how to collection input field data into Jtable with the following format. Please advise.</p> <ol> <li>text field
input
input  a java program that will exchange the last names of two students that were input by a user
PHP Prevent blank upload
PHP Prevent blank upload  In my small PHP application, i am posting... is that it also accepts blank data as well as duplicate value. Is there any way to check and prevent it from posting the blank value? Thanks
Struts2 blank application - Struts
Struts2 blank application  Hi I am new to struts2 and i am trying to run the strutsblank application by following the following Link; http://www.roseindia.net/struts/struts2/index.shtml As per the instructions given
How to design a blank CD, design a blank CD, blank CD
How to design a blank CD       This is a blank CD example, You will learn here how to make a blank CD by taking help of this example. New File: Take a new file with any
this is my file upload page, here i am not getting tags input field value to my servlet,please suggest a solution?
this is my file upload page, here i am not getting tags input field value to my... <input id="file' + counter + '" name = "file' + counter + '" type="file" /></td></tr>' + '<input id="Button' + counter
Running problem with NoughtsAndCrossesGame in blank
Running problem with NoughtsAndCrossesGame in blank  Hi i was having problem created NoughtsAndCrossesGame in end the it works but i runs the gui in blank. Its another way to solve it /* * To change this template, choose
Text Field in HTML
Text Field in HTML       The Text Field in HTML are one line areas, which enable the user to enter input text. Understand with Example The Tutorial illustrates an example from
Remove Extra Space At End
Remove Extra Space At End  Remove Extra Space At End
time and space complexity
time and space complexity  sort the data structures according to efficient time and space utilisation
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space error. This error is coming while...: Java heap space where there is no more space available for the Java program... space. You can also increase the Java heap space using following parameters
Program to Ignore Space and Enter ?!
Program to Ignore Space and Enter ?!  Hi, dear friend i wont to write program to enter many statements, if i use Space and Enter in the Run Time must be delete the space and ignore the Enter ..for example if i entered
java.lang.OutOfMemoryError: Java heap space
" java.lang.OutOfMemoryError: Java heap space How to resolve this issue? Thanks   Hi... your program. Check the thread Java heap space and java.lang.OutOfMemoryError: Java heap space. Thanks
xmlname space in java
xmlname space in java  hi i want to write code like , i used setAttribute method for this. but its showing ERROR: 'Namespace for prefix 'company' has not been declared.' javax.xml.transform.TransformerException
Java heap space
Java heap space  I am using MyEclipse 8.6 for my web based project. The command may be... Ex: java -Xms32m -Xmx128m How can I increase java heap space??? and Where to use this command exactly?   Following are few
how to space images in html code
how to space images in html code  how to space images in html code
space around/between my images
space around/between my images  How do I eliminate the space around/between my images
remove space - Java Beginners
remove space  I want to remove all line in text file using java. i want all text in single line. example. Input file This is text. I want remove all line. Output file This is text
Creating Blank DOM Document
Creating Blank DOM Document       This tutorial shows you how to create blank DOM document. JAXP... a blank document. The newDocument() method of the class returns a blank DOM
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads