The JDK 1.1 Event Model

The new event model is based on event sources and listeners. An object that wishes to listen for a particular event must ask a source of such an event to be added to its list of listeners.
For example: an object that wishes to handle a button click must implement an ActionListener interface, and must call the button's addActionListener method to be notified of button clicks.

The "listening" object wants to pass a pointer to a method to be called to the event source, but this is not possible in Java. Therefore it must pass itself instead.

AWT components all have add...Listener methods so they can register (listener) objects to send their events to.

For most types of events in AWT (but not "action") there is both a listener interface and and adapter class. Example:

public class myMouse implements MouseListener {
    ...
    public void mouseClicked(MouseEvent e) {
	// handle the click
    }
    public void mousePressed(MouseEvent e) {
	// handle the press
    }
    public void mouseReleased(MouseEvent e) {
	// handle the release
    }
    public void mouseEntered(MouseEvent e) {
	// handle the enter evemt
    }
    public void mouseExited(MouseEvent e) {
	// handle the mouse exit event
    }
    ...
}
or

public class myMouse extends MouseAdapter {
    ...
    public void mouseClicked(MouseEvent e) {
        // handle the click
    }
    // re-implement only those methods we need
    ...
}

The new event model is the main reason for using inner classes.