java.lang.Objectjava.awt.MenuComponent
java.awt.MenuItem
All Implemented Interfaces:
Accessible, Serializable
Direct Known Subclasses:
Menu, PopupMenu, CheckboxMenuItem
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.
Sami - Shaio| Nested Class Summary: | ||
|---|---|---|
| protected class | MenuItem.AccessibleAWTMenuItem | Inner class of MenuItem used to provide default support for
accessibility. This class is not meant to be used directly by
application developers, but is instead meant only to be
subclassed by menu component developers.
This class implements accessibility support for the
|
| Field Summary | ||
|---|---|---|
| boolean | enabled | A value to indicate whether a menu item is enabled
or not. If it is enabled, enabled will
be set to true. Else enabled will
be set to false.
|
| String | label | label is the label of a menu item.
It can be any string.
|
| String | actionCommand | This field indicates the command tha has been issued
by a particular menu item.
By default the actionCommand
is the label of the menu item, unless it has been
set using setActionCommand.
|
| long | eventMask | The eventMask is ONLY set by subclasses via enableEvents.
The mask should NOT be set when listeners are registered
so that we can distinguish the difference between when
listeners request events and subclasses request them.
|
| transient ActionListener | actionListener | |
| Fields inherited from java.awt.MenuComponent: |
|---|
| peer, parent, appContext, font, newEventsOnly, actionListenerK, itemListenerK, accessibleContext |
| Constructor: |
|---|
|
|
|
| Methods from java.awt.MenuComponent: |
|---|
| constructComponentName, dispatchEvent, dispatchEventImpl, eventEnabled, getAccessibleChildIndex, getAccessibleContext, getAccessibleIndexInParent, getAccessibleStateSet, getFont, getFont_NoClientCode, getName, getParent, getParent_NoClientCode, getPeer, getTreeLock, paramString, postEvent, processEvent, removeNotify, setFont, setName, toString |
| Methods from java.lang.Object: |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.awt.MenuItem Detail: |
|---|
Refer to AWT Threading Issues for details on AWT's threading model. |
|
|
MenuShortcut object associated
with this menu item. |
|
Deprecated! As - of JDK version 1.1,
replaced by setEnabled(boolean). |
|
|
Deprecated! As - of JDK version 1.1,
replaced by setEnabled(boolean). |
Deprecated! As - of JDK version 1.1,
replaced by setEnabled(boolean). |
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 |
|
|
|
|
|
|
FooListeners
upon this MenuItem.
FooListeners are registered using the
addFooListener method.
You can specify the ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));If no such listeners exist, this method returns an empty array. |
MenuShortcut object associated with this
menu item, |
|
|
|
MenuItem.
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null. |
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:
Note that if the event parameter is |
ActionEvent, it invokes
processActionEvent, another method
defined by MenuItem.
Currently, menu items only support action events. Note that if the event parameter is |
Refer to AWT Threading Issues for details on AWT's threading model. |
By default, the action command is set to the label of the menu item. |
|
|
MenuShortcut object associated with this
menu item. If a menu shortcut is already associated with
this menu item, it is replaced. |