1 | An Event Listener is an instance of any class that wants to receive events. |
2 | An event source is an object that generates events. An event source will keep a list of event listeners who want to be notified for particular events. |
3 | The event source notifies event listeners by invoking a particular method of the event listener (aka the event handler method) and passing it an Event object, which has all the information about the event. |
4 | For example, a component with a button is an event source, which generates an event called ActionEvent. There must be a class which implements an interface called ActionListener and which is on the list of listeners for that button. Then the Java system will provide the mechanism that passes the ActionEvent to a standard method of the ActionListener interface, namely a method called actionPerformed(). This method will receive the event object and carry out the response to the event. |