javax.swing
public class JMenuItem extends AbstractButton implements Accessible, MenuElement
Nested Class Summary | |
---|---|
protected class | JMenuItem.AccessibleJMenuItem
Provides the accessibility features for the JMenuItem
component.
|
Constructor Summary | |
---|---|
JMenuItem()
Creates a new JMenuItem object. | |
JMenuItem(Icon icon)
Creates a new JMenuItem with the given icon.
| |
JMenuItem(String text)
Creates a new JMenuItem with the given label.
| |
JMenuItem(Action action)
Creates a new JMenuItem associated with the specified action.
| |
JMenuItem(String text, Icon icon)
Creates a new JMenuItem with specified text and icon.
| |
JMenuItem(String text, int mnemonic)
Creates a new JMenuItem object.
|
Method Summary | |
---|---|
void | addMenuDragMouseListener(MenuDragMouseListener listener)
Adds a MenuDragMouseListener to this menu item. |
void | addMenuKeyListener(MenuKeyListener listener)
Adds an MenuKeyListener to this menu item. |
protected void | configurePropertiesFromAction(Action action)
Configures menu items' properties from properties of the specified action.
|
protected PropertyChangeListener | createActionPropertyChangeListener(Action action)
Creates PropertyChangeListener to listen for the changes in action
properties.
|
protected void | fireMenuDragMouseDragged(MenuDragMouseEvent event)
Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
|
protected void | fireMenuDragMouseEntered(MenuDragMouseEvent event)
Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
|
protected void | fireMenuDragMouseExited(MenuDragMouseEvent event)
Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
|
protected void | fireMenuDragMouseReleased(MenuDragMouseEvent event)
This method fires a MenuDragMouseEvent to all the MenuItem's MouseInputListeners.
|
protected void | fireMenuKeyPressed(MenuKeyEvent event)
This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
|
protected void | fireMenuKeyReleased(MenuKeyEvent event)
This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
|
protected void | fireMenuKeyTyped(MenuKeyEvent event)
This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
|
KeyStroke | getAccelerator()
Return accelerator for this menu item.
|
AccessibleContext | getAccessibleContext()
Returns the object that provides accessibility features for this
JMenuItem component.
|
Component | getComponent()
Returns reference to the component that will paint this menu item.
|
MenuDragMouseListener[] | getMenuDragMouseListeners()
Returns all added MenuDragMouseListener objects.
|
MenuKeyListener[] | getMenuKeyListeners()
Returns all added MenuKeyListener objects.
|
MenuElement[] | getSubElements()
Method of the MenuElement interface.
|
String | getUIClassID()
This method returns a name to identify which look and feel class will be
the UI delegate for the menuItem.
|
protected void | init(String text, Icon icon)
Initializes this menu item
|
boolean | isArmed()
Returns true if button's model is armed and false otherwise. |
void | menuSelectionChanged(boolean changed)
Method of the MenuElement interface.
|
protected String | paramString()
Returns a string describing the attributes for the JMenuItem
component, for use in debugging. |
void | processKeyEvent(KeyEvent event, MenuElement[] path, MenuSelectionManager manager)
Process key events forwarded from MenuSelectionManager.
|
void | processMenuDragMouseEvent(MenuDragMouseEvent event)
This method fires MenuDragMouseEvents to registered listeners.
|
void | processMenuKeyEvent(MenuKeyEvent event)
This method fires MenuKeyEvent to registered listeners.
|
void | processMouseEvent(MouseEvent ev, MenuElement[] path, MenuSelectionManager manager)
Process mouse events forwarded from MenuSelectionManager.
|
void | removeMenuDragMouseListener(MenuDragMouseListener listener)
Removes a MenuDragMouseListener from the menuItem's listener list.
|
void | removeMenuKeyListener(MenuKeyListener listener)
Removes an MenuKeyListener from the menuItem's listener list.
|
void | setAccelerator(KeyStroke keystroke)
Sets the key combination which invokes the menu item's action
listeners without navigating the menu hierarchy. |
void | setArmed(boolean armed)
Sets menuItem's "ARMED" property
|
void | setEnabled(boolean enabled)
Enable or disable menu item. |
void | setUI(MenuItemUI ui)
Set the "UI" property of the menu item, which is a look and feel class
responsible for handling menuItem's input events and painting it.
|
void | updateUI()
This method sets this menuItem's UI to the UIManager's default for the
current look and feel. |
Parameters: icon Icon that will be displayed on the menu item
Parameters: text label for the menu item
Parameters: action action for this menu item
Parameters: text label for this menu item icon icon that will be displayed on this menu item
Parameters: text label for this menu item mnemonic - Single key that can be used with a look-and-feel meta key to activate this menu item. However menu item should be visible on the screen when mnemonic is used.
Parameters: listener The new listener to add
Parameters: listener The new listener to add
Parameters: action action to configure properties from
Parameters: action action to listen to for property changes
Returns: $PropertyChangeListener$ Listener that listens to changes in action properties.
Parameters: event The event signifying that mouse is being dragged over the menuItem
Parameters: event The event signifying that mouse entered menuItem while it was dragged
Parameters: event The event signifying that mouse has exited menu item, while it was dragged
Parameters: event The event signifying that mouse was released while it was dragged over the menuItem
Parameters: event The event signifying that key associated with this menu was pressed
Parameters: event The event signifying that key associated with this menu was released
Parameters: event The event signifying that key associated with this menu was typed. The key is typed when it was pressed and then released
Returns: $KeyStroke$ accelerator for this menu item.
JMenuItem
component.
Returns: The accessible context (an instance of {@link AccessibleJMenuItem}).
Returns: $Component$ Component that will paint this menu item. Simply returns reference to this menu item.
Returns: an array of listeners
Since: 1.4
Returns: an array of listeners
Since: 1.4
Returns: $MenuElement[]$ Returns array of sub-components for this menu item. By default menuItem doesn't have any subcomponents and so empty array is returned instead.
Returns: The Look and Feel classID. "MenuItemUI"
Parameters: text label for this menu item icon icon to be displayed for this menu item
Returns: $boolean$ true if button's model is armed and false otherwise
Parameters: changed indicates selection status of this menu item. If changed is true then menu item is selected and deselected otherwise.
JMenuItem
component, for use in debugging. The return value is guaranteed to be
non-null
, but the format of the string may vary between
implementations.
Returns: A string describing the attributes of the JMenuItem
.
Parameters: event event forwarded from MenuSelectionManager path path to the menu element from which event was generated manager MenuSelectionManager for the current menu hierarchy
Parameters: event Mouse
Parameters: event DOCUMENT ME!
Parameters: ev event forwarded from MenuSelectionManager path path to the menu element from which event was generated manager MenuSelectionManager for the current menu hierarchy
Parameters: listener The listener to remove
Parameters: listener The listener to remove
Parameters: keystroke accelerator for this menu item.
Parameters: armed DOCUMENT ME!
Parameters: enabled if true enable menu item, and disable otherwise.
Parameters: ui The new "UI" property