java - Listeners and their objects -


i have jtextfield listener change-text event.

can use listener affect same object listening to? instance, if detects "problematic" change, should delete text in same jtextfield object.

is possible? doesn't seem work...

an example follows: .

this.txtsearch.getdocument().adddocumentlistener(new documentlistener() { public void changedupdate(documentevent e) {     validate(); }  public void removeupdate(documentevent e) {     validate(); }  public void insertupdate(documentevent e) {     validate(); }  private void validate(){     if not_good(txtsearch.gettext()) {         txtsearch.settext("");     } } 

changing text in jtextfield textchanged event cause (possibly infinite) loop of textchanged events. not that.

if want validate input jtextfield rather use inputverifier.

the javadoc contains some examples of how use it, have look.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -