Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton enabling and disabling  RSS feed

 
Kwesi Prat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some text fields an an ok and cancel buttons. I want the program in such a way that the ok button is disabled what there in no nothing in the text field an becomes enabled when somthing is typed into the text field. Also when the cancel button is pressed, ann the numbers ib the text field get erased. Could someon come to my aid, please.
Thank you.
Kwesi.
 
Pete Tibbitts
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've done a similar thing by adding a document listener to the text field with the following method

and then i've got another method which is called everytime the textfield is updated which contains the logic to determine whether the button is enabled / disabled........

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!