The event listener frame work works as follows:
- Create a subclass of EventObject (or any of its subclasses like ActionEvent), let's call it MyEvent
- Create a subinterface of EventListener (or any of its subinterfaces like ActionListener), let's call it MyListener
- Give MyListener one method for each type of event with MyEvent as the parameter:
- If your listener has more than one method and you like your users, create an adapter with empty-body implementations:
That way, users only need to override the methods they need to implement.
As for calling the listeners, there are two ways:
1) use a List<MyListener>:
2) use an EventListenerList:
I'd go for EventListenerList if you need more than one listener type.