java - Unlock JButton as fields have text -



java - Unlock JButton as fields have text -

as topic suggests want unlock(setenabled(true)) jbutton register when other fields have text don't know type of listener this. upload image clearer understanding. http://postimg.org/image/ab8alz44d/

add document listener each text field.

void init() { //construct text fields ... // add together listeners textfield1.getdocument().adddocumentlistener(new documentlistener() { public void changedupdate(documentevent e) { checkunlock(); } public void removeupdate(documentevent e) { checkunlock(); } public void insertupdate(documentevent e) { checkunlock(); }); // repeat each textfield } ... private void checkunlock() { boolean unlock = !(textfield1.gettext().equals("")) && !(textfield2.gettext().equals("")); // ... , on yourbutton.setenabled(unlock); }

java swing jbutton enable-if

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -