implements it. As with abstract
classes, all of the abstract methods in an interface must be overridden
by classes which implement the interface.
ActionEvent, WindowEvent,
MouseEvent, ItemEvent, and
KeyEvent.
When the user takes an action on a component, an event object is
automatically created.
WindowListener,
MouseListener,
ActionListener,
ItemListener, and
KeyListener.
Each listener has astract methods which specify how the program is to respond
when a particular type of event occurs.
Each component type has methods to add listeners of particular types to
it.
When the user takes an action on a component which has a listener listening to it,
the appropriate method is called in the listener with the event object as its
argument.
To implement event handling for a component:
implementing
one of the listener interfaces. The listener can be the component
itself, another component which contains the component, or a
separate listener object (using a defined class for this).addMouseListener.actionPerformed,
mouseClicked, windowOpening.
mouseClicked takes
MouseEvent and
actionPerformed takes
an ActionEvent.MouseEvents have methods
getX() and
getY()
which return the x and y coordinates of the
MouseEvent within the component where it occurs.