how to check TextField is empty
984449Jan 11 2013 — edited Jan 11 2013Hello,
I am quite new to Java.
I am trying to make a simple program which is just for practical purpose.
Now, i have a JPanel and I put 2 different buttons (first button called:5, Second button called:4)there on the right side of the panel.
On the left side, there are a few TextFields, which I named display1b,display2b,display3b...
Now , when i click the button 5, First i like to check the first TextField (display1b) value and if it is empty then change the value to "5". If it is not then check the second TextField and if this one is empty, change the value to "5", if it is not check the next and then the next....
This is my code.
####
private void fiveActionPerformed(java.awt.event.ActionEvent evt) {
//checking if the text area is empty:
if((display1b == null)){
display1b.setText("5");
} else
if((display2b == null)){
display2b.setText("5");
}
}
###
can anyone tell me where am i doing wrong?
thanks in advance..