Hi, let's say i have a jframe which has 2 JTextFields and JButton to process smth when it is pressed. Processing needs apropriate values from those two text fields. When the button is pressed i want to check if user filled both fields and if not so, warn him. However i can not find out what is returned by JTextField's method getText() when text field is empty. That is not null and not empty String. Any help?
3 replies to this topic
#1
Posted 01 February 2011 - 12:56 PM
|
|
|
#2
Posted 01 February 2011 - 01:58 PM
Did you try to assign a String value using getText()
String someThing = "texfieldName".getText()
// which should allow you to
if (something.length() == 0){
throw noInputException();
}"
#3
Posted 01 February 2011 - 05:38 PM
If im correct, you are trying to find out if the textField is empty?
if so use this
if so use this
if(txtField.getText().trim().equals("")){
//code here
}
#4
Posted 02 February 2011 - 06:35 AM
thanks, it's clear now
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









