Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to check TextField is empty

984449Jan 11 2013 — edited Jan 11 2013
Hello,

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..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 8 2013
Added on Jan 11 2013
1 comment
1,926 views