Java Reference
In-Depth Information
The base class for all semantic
events. There are semantic events
specific to Swing components
derived directly from this class.
In package java.util
EventObject
AWTEvent
In package java.awt
ActionEvent
ItemEvent
AdjustmentEvent
These three semantic event classes are in java.awt.event
An ActionEvent is generated when you perform an action on a component such as clicking on a
menu item or a button. An ItemEvent occurs when a component is selected or deselected and an
AdjustmentEvent is produced when an adjustable object, such as a scrollbar, is adjusted.
Different kinds of components can produce different kinds of semantic events. The components that can
originate these events are:
Event Type
Produced by Objects of Type
ActionEvent
Buttons:
JButton , JToggleButton , JCheckBox
Menus:
JMenuItem , JMenu , JCheckBoxMenuItem ,
JRadioButtonMenuItem
Text:
JTextField
ItemEvent
Buttons:
JButton , JToggleButton , JCheckBox
Menus:
JMenuItem , JMenu , JCheckBoxMenuItem ,
JRadioButtonMenuItem
AdjustmentEvent
JScrollbar
These three types of event are also generated by the old AWT components but we won't go into these
here as we are concentrating on the Swing components. Of course, any class you derive from these
component classes to define your own customized components can be the source of the event that the
base class generates. If you define your own class for buttons, MyFancyButton say, your class will
have JButton as a base class, inherit all of the methods from the JButton class, and objects of your
class will originate events of type ActionEvent and ItemEvent .
Search WWH ::




Custom Search