Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField  RSS feed

 
JAY MaCaNaWallChucK
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all i need a hand with my home work im mad stuck..he he he
here is my problem
what dose JTextField return when nothing is entered in to the text feild and how would i go a bout checking for a null in the text feild...
this is what I tried
JTextField emp = new JTextField(20);
if(emp.getText()==null){
do this
}else{
do this
}
i did a System.out.println(emp.getText());
and it dumps a space in the console
Plz Help
Thankz
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check also the length of the string that is returned:

if you also want to check whether the string consists only of whitespace, you will have to use either regular expression or iterate over the string. e.g.:
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ups, change it to:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!