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.
-
public class EventClass implements ActionListener
-
{
-
public void actionPerformed ( ActionEvent ev )
-
{. . . put code here to respond to event ev . . . }
-
}
|
Each basic component has a defined Event class, Listener interface, and event handling method names.
|
Note that an interface is a class in which there are headers of methods with no method body. It just gives the name(s) of methods such as actionPerformed that the user is to provide.
|