Based on concept of "event listener":
-
An event listener is any object which wants to receive events.
-
An event source is an object which generates events. An event source will keep a list of event listeners who want to be notified for particular events.
-
The event source notifies event listeners by invoking a particular method in the event listener and passing it an event object, which has all the information about the event.
-
Example: a component with a button is an event source. Formerly, a button click was reported to the action method of the component. The button click event is now called ActionEvent. You must write a class which implements ActionListener (which can be local to the component) and which provides a method called actionPerformed(). This method will receive the event object and take appropriate action.
|