java - Grayed out textfield unless checkbox ticked -


how, using jtextfield, can create program enable/disable textfield depending on whether or not checkbox ticked?

i have option which, if checked, needs take input. if not checked, i'd text field remain grayed out user unable enter text.

mchq08 did not give complete answer since code nothing if jcheckbox unchecked. don't need if block you'd need single line of code in item listener

checkbox.additemlistener(new itemlistener() {   public void itemstatechanged(itemevent itemevent){     // line below line matters, enables/disables text field     textfield.setenabled(itemevent.getstatechange() == itemevent.selected);   } }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -