Java Reference
In-Depth Information
Just so that you know, this isn't an exhaustive list of all of the low-level event classes.
It's a list of the ones you need to know about. For example, there's the PaintEvent
class that is concerned with the internals of how components get painted on the screen.
There's also another low-level event class, ContainerEvent , which defines events
relating to a container such as adding or removing components. You can ignore this
class as these events are handled automatically.
Each of these classes defines methods that enable you to analyze the event. For a MouseEvent object, for
example, you can get the coordinates of the cursor when the event occurred. These low-level event classes
also inherit methods from their superclasses, and are related in the manner shown in the diagram:
In package
java.awt
AWTEvent
All other classes are in
java.awt.event
ComponentEvent
WindowEvent
InputEvent
FocusEvent
MouseEvent
KeyEvent
The class AWTEvent is itself a subclass of java.util.EventObject . The EventObject class
implements the Serializable interface, so all objects of the event classes in the diagram are
serializable. It also defines a method, getSource() , which returns the object that is the source of an
event as type Object . All the event classes shown inherit this method.
The class AWTEvent defines constants, which are public final values identifying the various kinds
of events. These constants are named for the sake of consistency as the event name in capital letters,
followed by _ MASK . The constants identifying the low-level events that you are most likely to be
interested in are:
MOUSE _ EVENT _ MASK
MOUSE _ MOTION _ EVENT _ MASK
MOUSE _ WHEEL _ EVENT _ MASK
KEY _ EVENT _ MASK
ADJUSTMENT _ EVENT _ MASK
TEXT _ EVENT _ MASK
WINDOW _ EVENT _ MASK
WINDOW _ FOCUS _ EVENT _ MASK
WINDOW _ STATUS _ EVENT _ MASK
ITEM _ EVENT _ MASK
FOCUS _ EVENT _ MASK
Each of these constants is a value of type long with a single bit being set to 1 and all the remaining set
to 0. Because they are defined this way you can combine them using a bitwise OR operator and you can
separate a particular constant out from a combination by using a bitwise AND.
Search WWH ::




Custom Search