Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners blank space in input field

Have Programming Question? Ask it here!
 
 
 


praveena
blank space in input field
1 Answer(s)      4 years and a month 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.

Advertisement
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
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 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
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
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
input
input  a java program that will exchange the last names of two students that were input by a user
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
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
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
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
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
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
space around/between my images
space around/between my images  How do I eliminate the space around/between my images
how to space images in html code
how to space images in html code  how to space images in html code
Creating Blank DOM Document
Creating Blank DOM Document       This tutorial shows you how to create blank DOM document. JAXP (Java... of the class DocumentBuilder is used to create a blank document. The newDocument
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
Use of Text Field
Use of Text Field, Text box, Text Area, Checkbox,Dropdownlist and Radio... types of information. A form contains form elements checkbox, text field, radio button etc.) through which users can input their data. A form is created using
Set Space Ratio and Alignment
Set Space Ratio and Alignment     ... are going to explain how we can set space ratio and how we can gives various alignment. You can make pdf with no space between the characters of a word
space between buttons iPhone SDK
space between buttons iPhone SDK  Hi, can any one please explain how to add space between UIButtons in iPhone SDK. Actually i am creating Multiple UIButton's and added them to my UIScrollView. But problem is that those buttons
Input - Output String Functions
Input - Output String Functions      ... data from a user (text field, text area) since it is not secure to receive a string data and input them directly into your database. Some special characters
input output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part... character input stream and buffering characters. It also reads
White Space encoding problem in PDF
White Space encoding problem in PDF  I am reading PDF version 1.3 using iText. Things are fine but with one problem that is I am not able to get whitespace. Is there any problem in whitespace encoding in PDF version 1.3
Array and input
to input one of the above numbers then i want to print the array without the number user input. how will i do tht
keyboard input
keyboard input  how do I use JOptionPane to accept keyboard input? I know how to import but not specific command on input line   import javax.swing.*; class JOPtionPaneExample { public static void main(String
text field
text field  How to retrieve data from text field   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
Find total disk space in PHP, php disk_total_space, disk_total_space
Learn How to Get the total disk space in PHP Program. In this PHP Tutorial example we will use the disk_total_space() function in our PHP code to find the total disk space. syntax disk_total_space() Function PHP disk_total_space
using java.lang.OutOfMemoryError: Java heap space
and my program has this error "using java.lang.OutOfMemoryError: Java heap space
Display free disk space
Description: This example will demonstrate how to get the free disk space... in java.io.File. This method get the free disk space in the bytes. Code... upon number of drive you have and the free space available. Note
there extra space before or after my table.
there extra space before or after my table.  Why is there extra space before or after my table
eliminate the extra space after a </form> tag
eliminate the extra space after a tag  How can I eliminate the extra space after a tag
PHP find free space, php disk_free_space, disk_free_space
The example Shows of disk_free_space() function in php Program. In this section you will find the example code of disk_free_space() function. The disk_free_space() function in PHP is used to find the Hard Disk's free space from
java heap space & netbeans - Java Beginners
java heap space & netbeans  Java heap space". I'm using netbeans 5.1.1 and jdk1.5.0_07 version.. can any body say how can i know the amount of java heap space while i run...java heap space & netbeans Hey,all!! I've got a problem
File Upload in struts2 - Invalid field value for field
File Upload in struts2 - Invalid field value for field   Hi I am... : Invalid field value for field "upload". My webContents->Web-Inf->lib...;/result> <result name="input">/upload.jsp</result> <
Java file get total space
Java file get total space In this section, you will learn how to get the total space of disc. Description of code: JDK 1.6 provides few new methods... These methods provides essential information regarding disk space. In the given
Advertisements
 

 

 

DMCA.com