
CHAPTER 14
Thejava.awt.event Package
The java.awt.event package defines classes and interfaces used for event handling in
the AWT and Swing. The members of this package fall into three categories:
Events
The classes with names ending in “Event” repr esent specific types of events,
generated by the AWT or by one of the AWT or Swing components.
Listeners
The interfaces in this package are all event listeners; their names end with
“Listener”. These interfaces define the methods that must be implemented by
any object that wants to be notified when a particular event occurs. Note that
ther e is a Listener inter face for each Event class.
Adapters
Each of the classes with a name ending in “Adapter” provides a no-op imple-
mentation for an event listener interface that defines more than one method.
When you are inter ested in only a single method of an event listener inter-
face, it is easier to subclass an Adapter class than to implement all of the meth-
ods of the corresponding Listener inter face.
Figur e 14-1 shows the class hierarchy of this package.
The Swing user-inter face components use some of these event classes and inter-
faces and also define others in the javax.swing .event package. The java.beans package
also defines a few commonly used event classes and listener interfaces. Note that
this package is part of the Java 1.1 event model. In Java 1.0, events were repr e-
sented by the java.awt.Event class. ...