This javaworld article describes how to create custom events and eventlisteners.
There are three main components in event-driven programming:
*EventObject class
*EventListener interface
*EventGenerator class
The EventObject class extends the java.util.EventObject class and knows the event generator object.
The EventListener interface supplies the method that is to be invoked when the event is generated.
The EventGenerator contains the list of eventlisteners registered for that event. Whenever the event is generated, it iterates through the listeners and invokes their eventlistener method eg. public void actionPerformed() for an ActionEvent.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment