java - How to reference a DocumentListener created via class -


i create documentlisteners so:

mydocumentlistener dl = new mydocumentlistener(); tab.getdocument().adddocumentlistener( dl ); 

mydocumentlistener class provides event handling. however, want remove documentlistener not know how reference mydocumentlistener object created.

the short answer is: need store mydocumentlistener object created someplace can access it. don't know structure of code, cannot best location save it. if want remove document listener added, do:

mydocumentlistener dl = new mydocumentlistener(); tab.getdocument().adddocumentlistener( dl ); tab.getdocument().removedocumentlistener( dl ); 

...but that's not want (why remove document listener added?) so, consider editing question more details structure of software, perhaps answerers can propose locations store documentlistener created.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -