I would like check to see if the user entered any value in a JTextField before clicking a JButton in order determine the branch to take in a conditional statement. In the JButton actionPerformed() method I have a statement such as:
if(JTextField1.getText() == null){
... do something ...
}
else{
... do something else ...
}
My problem is that 'null' does not appear to be returned from an empty JTextField, nor is an empty String (i.e. ""
. How can I determine the JTextField did not have anything entered into it when the button was clicked?
if(JTextField1.getText() == null){
... do something ...
}
else{
... do something else ...
}
My problem is that 'null' does not appear to be returned from an empty JTextField, nor is an empty String (i.e. ""