jtextfield question

hello all

i have a jtextfield that i use its text to retrieve information from a database, my problem is that i dont want this textfield to be empty when i press the button in order to retrieve info from the database

i tried the following

if(text.getDocument().getLength() == 0){

JOptionPane.showMessageDialog(null

,"Please enter some valid input"

,"ERROR"

, JOptionPane.ERROR_MESSAGE);

return;

}

but it does not work if u press the space button once...

is there is a more professional way to do it

please help

thanks in advance

[815 byte] By [bif_fa] at [2007-11-27 5:43:44]
# 1
assuming that "text" is a JTextField:if (text.getText().trim().length() == 0) {...}
dwga at 2007-7-12 15:23:40 > top of Java-index,Desktop,Core GUI APIs...