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
Post a Comment