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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -