Java Interface
tonyn | November 13, 2008[public] interface interface-name {
[class-variable-declaration(s)]
[abstract-method-declaration(s)]
}
Implementing event handlings
public void addCategoryListener(CateoryListener l)
Defines another method
public void removeCategoryListener(CategoryListener)
addXXX();
removeXXX();
-
Example:
public void addActionListener(ActionListener l)
public void removeActionListener(ActionListener l)
-
The steps in setting up event handling for a GUI are:
1. Identify the category of the event the GUI component is expected to handle.
2. Write an event handler class that implements the listener interface.
3. While constructing the GUI, create the GUI component and an object of the event handler class.
4. Call the addXXX() method of the GUI component to register the event handler object to be its event handler.