Home Answers Viewqa Java-Beginners blank space in input field

 
 


praveena
blank space in input field
1 Answer(s)      3 years and 2 months 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.
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 Pages:
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
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
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
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
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>
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
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
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?  We would like to know how to collection input field data into Jtable with the following format. Please advise. text field - input amount text year - input year text
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
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
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> <
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
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
javascript focus input
input field in the page. It can be performed using focus() method on the html element. To understand how focus can be set to any input field, we have created... into it. Clicking the OK button on the alert box takes the focus to the name input field
input
input  a java program that will exchange the last names of two students that were input by a user
how to perform a validation for the field
validate()"> <pre> Enter Name: <input type...;input type="text" name="email" size="30"><br> Enter Address...; </select><br> <input type="submit" name
how to perform a validation for the field
validate()"> <pre> Enter Name: <input type...;input type="text" name="email" size="30"><br> Enter Address...; </select><br> <input type="submit" name
Password Field in HTML
Password Field in HTML       When users type characters in a password field, the browser displays asterisks or bullets instead of the characters. Password text field is same
HTML5 input examples, Introduction and implementation of input tag.
HTML5 input examples, Introduction and implementation of input tag. Introduction:In this tutorial, you will see the use of input tag. The input tag is a input field in a form. In which user can insert data, and the type of data
Input And Output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part of java.io... input stream and buffering characters. It also reads characters, arrays
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
Example of struts2.2.1 field validator.
Example of struts2.2.1 field validator. In this section, you will see the use how to validate form field or user input in struts2. Struts2 used a xml... for defining validator in XML file. Field validator Non-field validator
rexexp pattern to avoid certain words and replace space with underscore
rexexp pattern to avoid certain words and replace space with underscore ... to replace space between two capital words with underscore so that "River Thames... with this pattern is that it also replaces the space between "On River" to "OnRiver" and after
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
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
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
HTML5 input autofocus, html5 input required.
HTML5 input autofocus, html5 input required. Introduction:Here we will introduce you to about the autofocus and required attribute of input tag. Type.... User must fill this field. Declaration Syntax :  
iphone text field example
in this application, First 2 takes the input from the user and the last text field... readable. Now go to Tools->Inspector->Text Field Attributes-> Interaction... and in action we are writing the two string into different field and showing
Java Servlet : Hidden Field
field as - <input type =?hidden? name =?name? value=?value?/> In servlet you...Java Servlet : Hidden Field In this tutorial, we will discuss about Hidden Field. It is one of session tracking technique. Hidden Field : Session
Java Password Field
Java Password Field In this section we will discuss how to use password field in Java. To create a password field in Java Swing JPasswordField is used... of text field which allows to enter password only. Due to the security reason
HTML5 input attribute, Define the type, alt and image  of input tag.
HTML5 input attribute, Define the type, alt and image  of input tag. Introduction:Here we will introduce you to about the type attribute of input tag... only given type of data. It is most important for input tag. The alt 
input type checkbox HTML5,  input type radio HTML5.
input type checkbox HTML5,  input type radio HTML5. Introduction:In this tutorial, you will the use of  checkbox and radio type input field...;/head> <body> <form> <h2>Input tag.</h2> <
iPhone Text Field Validation
data from user. In this tutorial we are going to limiting the text field input...;. We have also take a Text field on the view to take the input from user... iPhone Text Field Validation In any user based application "
Using Non Field Validators
Using Non Field Validators You can use non-field validators for server side...; An Example using non field validators is goven below login.jsp <%@ taglib... = password; } public String display(){ return "input
fetch values from database into text field
the example for fetching values from database into text field of table wth edit...;<input type=\"hidden\" name=\"P_ID\" value=\"rs.getString(1)\"></td>"); out.println("<td><input type=\"text\" name=\"LASTNAME\" value
fetch values from database into text field
the example for fetching values from database into text field of table as if i am...()) { out.println("<tr>"); out.println("<td><input type=\"hidden\" name=\"P_ID\" value=\"rs.getString(1)\"></td>"); out.println("<td><input
JavaScript Array from Input
you easy to understand an example of  Array from Input. The example create a HTML Page JavaScript array from input include a text name 'name', a text field... JavaScript Array from Input   
set text field appearance to default - Java Beginners
set text field appearance to default  hi, i am doing a program, in which i have a form for the user to input some data. i wanted to change the border color of a text box if the input was incorrect, but when i fail to set
time and space complexity
time and space complexity  sort the data structures according to efficient time and space utilisation
Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature of various O/S, are read through standard input in Java. Standard streams are read
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
Validator in Flex4
Validator in Flex4: The Validator class validates the text field value. If the text is blank it will give an error message. If you will write anything in the text field then it will not generate a error message. Basically it is used
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.