J
Jeffrey Schwab
Every time I write a class that's an event source, I give it a private
list of event listeners, add/removeListener methods, etc. What's the
better way to maintain a list of listeners? I could use
javax.swing.event.EventListenerList, but it has significant
shortcomings:
- The javadocs do not specify what happens when a listener is
added or removed multiple times.
- Proper use of EventListenerList requires a fair amount of
boilerplate code.
- It feels a little sketchy to use a Swing utility class when
I'm not using any other Swing components.
What do you consider best practice, and what are the most reasonable
alternatives?
list of event listeners, add/removeListener methods, etc. What's the
better way to maintain a list of listeners? I could use
javax.swing.event.EventListenerList, but it has significant
shortcomings:
- The javadocs do not specify what happens when a listener is
added or removed multiple times.
- Proper use of EventListenerList requires a fair amount of
boilerplate code.
- It feels a little sketchy to use a Swing utility class when
I'm not using any other Swing components.
What do you consider best practice, and what are the most reasonable
alternatives?