Is there an easy way to remove all listeners from JComponent?
JComponent widget = getComponentOverScaryMethod(); EventListener[] listners = widget.getListeners(EventListener.class); for (EventListener l : listners) { widget.remove*RandomListener*(l); }
Background:
I have a JComponent with an unknown number of Listeners (random types). Since the widget must be removed from the visible part (and no longer needed), it must be destroyed (and Listeners must be removed).
Thanks in advance Joan
java listener swing
Joan wilkinson
source share