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 -

java - Could not locate OpenAL library -

Non Unique Username with ASP.Net Identity 2.0 -