All items in a menu must belong to the class
MenuItem, or one of its subclasses.
The default MenuItem object embodies
a simple labeled menu item.
This picture of a menu bar shows five menu items:
The first two items are simple menu items, labeled
"Basic" and "Simple".
Following these two items is a separator, which is itself
a menu item, created with the label "-".
Next is an instance of CheckboxMenuItem
labeled "Check". The final menu item is a
submenu labeled "More Examples",
and this submenu is an instance of Menu.
When a menu item is selected, AWT sends an action event to
the menu item. Since the event is an
instance of ActionEvent, the processEvent
method examines the event and passes it along to
processActionEvent. The latter method redirects the
event to any ActionListener objects that have
registered an interest in action events generated by this
menu item.
Note that the subclass Menu overrides this behavior and
does not send any event to the frame until one of its subitems is
selected.
Enables event delivery to this menu item for events
to be defined by the specified event mask parameter
Since event types are automatically enabled when a listener for
that type is added to the menu item, this method only needs
to be invoked by subclasses of MenuItem which desire to
have the specified event types delivered to processEvent
regardless of whether a listener is registered.
Constructs a new MenuItem with the specified label
and no keyboard shortcut. Note that use of "-" in
a label is reserved to indicate a separator between
menu items. By default, all menu items except for
separators are enabled.
Create a menu item with an associated keyboard shortcut.
Note that use of "-" in a label is reserved to indicate
a separator between menu items. By default, all menu
items except for separators are enabled.
Parameters:
label - the label for this menu item.
s - the instance of MenuShortcut
associated with this menu item.
Delete any MenuShortcut object associated
with this menu item.
enableEvents
protected final void enableEvents(long eventsToEnable)
Enables event delivery to this menu item for events
to be defined by the specified event mask parameter
Since event types are automatically enabled when a listener for
that type is added to the menu item, this method only needs
to be invoked by subclasses of MenuItem which desire to
have the specified event types delivered to processEvent
regardless of whether a listener is registered.
Parameters:
eventsToEnable - the event mask defining the event types.
Processes action events occurring on this menu item,
by dispatching them to any registered
ActionListener objects.
This method is not called unless action events are
enabled for this component. Action events are enabled
when one of the following occurs:
An ActionListener object is registered
via addActionListener.