An implementation of an item in a menu. A menu item is essentially a button sitting in a list. When the user selects the "button", the action associated with the menu item is performed. A JMenuItem contained in a JPopupMenu performs exactly that function.
Menu items can be configured, and to some degree controlled, by Actions. Using an Action with a menu item has many benefits beyond directly configuring a menu item. Refer to Swing Components Supporting Action for more details, and you can find more information in How to Use Actions, a section in The Java Tutorial.
For further documentation and for examples, see How to Use Menus in The Java Tutorial.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
An implementation of an item in a menu. A menu item is essentially a button sitting in a list. When the user selects the "button", the action associated with the menu item is performed. A JMenuItem contained in a JPopupMenu performs exactly that function. Menu items can be configured, and to some degree controlled, by Actions. Using an Action with a menu item has many benefits beyond directly configuring a menu item. Refer to Swing Components Supporting Action for more details, and you can find more information in How to Use Actions, a section in The Java Tutorial. For further documentation and for examples, see How to Use Menus in The Java Tutorial. Warning: Swing is not thread safe. For more information see Swing's Threading Policy. Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
(->j-menu-item)
(->j-menu-item icon)
(->j-menu-item text icon)
Constructor.
Creates a JMenuItem with the specified text and icon.
text - the text of the JMenuItem - java.lang.String
icon - the icon of the JMenuItem - javax.swing.Icon
Constructor. Creates a JMenuItem with the specified text and icon. text - the text of the JMenuItem - `java.lang.String` icon - the icon of the JMenuItem - `javax.swing.Icon`
(add-menu-drag-mouse-listener this l)
Adds a MenuDragMouseListener to the menu item.
l - the MenuDragMouseListener to be added - javax.swing.event.MenuDragMouseListener
Adds a MenuDragMouseListener to the menu item. l - the MenuDragMouseListener to be added - `javax.swing.event.MenuDragMouseListener`
(add-menu-key-listener this l)
Adds a MenuKeyListener to the menu item.
l - the MenuKeyListener to be added - javax.swing.event.MenuKeyListener
Adds a MenuKeyListener to the menu item. l - the MenuKeyListener to be added - `javax.swing.event.MenuKeyListener`
(armed? this)
Returns whether the menu item is "armed".
returns: true if the menu item is armed, and it can be selected - boolean
Returns whether the menu item is "armed". returns: true if the menu item is armed, and it can be selected - `boolean`
(get-accelerator this)
Returns the KeyStroke which serves as an accelerator for the menu item.
returns: a KeyStroke object identifying the
accelerator key - javax.swing.KeyStroke
Returns the KeyStroke which serves as an accelerator for the menu item. returns: a KeyStroke object identifying the accelerator key - `javax.swing.KeyStroke`
(get-accessible-context this)
Returns the AccessibleContext associated with this JMenuItem. For JMenuItems, the AccessibleContext takes the form of an AccessibleJMenuItem. A new AccessibleJMenuItme instance is created if necessary.
returns: an AccessibleJMenuItem that serves as the
AccessibleContext of this JMenuItem - javax.accessibility.AccessibleContext
Returns the AccessibleContext associated with this JMenuItem. For JMenuItems, the AccessibleContext takes the form of an AccessibleJMenuItem. A new AccessibleJMenuItme instance is created if necessary. returns: an AccessibleJMenuItem that serves as the AccessibleContext of this JMenuItem - `javax.accessibility.AccessibleContext`
(get-component this)
Returns the java.awt.Component used to paint this object. The returned component will be used to convert events and detect if an event is inside a menu component.
returns: the Component that paints this menu item - java.awt.Component
Returns the java.awt.Component used to paint this object. The returned component will be used to convert events and detect if an event is inside a menu component. returns: the Component that paints this menu item - `java.awt.Component`
(get-menu-drag-mouse-listeners this)
Returns an array of all the MenuDragMouseListeners added to this JMenuItem with addMenuDragMouseListener().
returns: all of the MenuDragMouseListeners added or an empty
array if no listeners have been added - javax.swing.event.MenuDragMouseListener[]
Returns an array of all the MenuDragMouseListeners added to this JMenuItem with addMenuDragMouseListener(). returns: all of the MenuDragMouseListeners added or an empty array if no listeners have been added - `javax.swing.event.MenuDragMouseListener[]`
(get-menu-key-listeners this)
Returns an array of all the MenuKeyListeners added to this JMenuItem with addMenuKeyListener().
returns: all of the MenuKeyListeners added or an empty
array if no listeners have been added - javax.swing.event.MenuKeyListener[]
Returns an array of all the MenuKeyListeners added to this JMenuItem with addMenuKeyListener(). returns: all of the MenuKeyListeners added or an empty array if no listeners have been added - `javax.swing.event.MenuKeyListener[]`
(get-sub-elements this)
This method returns an array containing the sub-menu components for this menu component.
returns: an array of MenuElements - javax.swing.MenuElement[]
This method returns an array containing the sub-menu components for this menu component. returns: an array of MenuElements - `javax.swing.MenuElement[]`
(get-ui-class-id this)
Returns the suffix used to construct the name of the L&F class used to render this component.
returns: the string "MenuItemUI" - java.lang.String
Returns the suffix used to construct the name of the L&F class used to render this component. returns: the string "MenuItemUI" - `java.lang.String`
(menu-selection-changed this is-included)
Called by the MenuSelectionManager when the MenuElement is selected or unselected.
is-included - true if this menu item is on the part of the menu path that changed, false if this menu is part of the a menu path that changed, but this particular part of that path is still the same - boolean
Called by the MenuSelectionManager when the MenuElement is selected or unselected. is-included - true if this menu item is on the part of the menu path that changed, false if this menu is part of the a menu path that changed, but this particular part of that path is still the same - `boolean`
(process-key-event this e path manager)
Processes a key event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using MenuSelectionManager's API.
Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager.
e - a KeyEvent - java.awt.event.KeyEvent
path - the MenuElement path array - javax.swing.MenuElement[]
manager - the MenuSelectionManager - javax.swing.MenuSelectionManager
Processes a key event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using MenuSelectionManager's API. Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager. e - a KeyEvent - `java.awt.event.KeyEvent` path - the MenuElement path array - `javax.swing.MenuElement[]` manager - the MenuSelectionManager - `javax.swing.MenuSelectionManager`
(process-menu-drag-mouse-event this e)
Handles mouse drag in a menu.
e - a MenuDragMouseEvent object - javax.swing.event.MenuDragMouseEvent
Handles mouse drag in a menu. e - a MenuDragMouseEvent object - `javax.swing.event.MenuDragMouseEvent`
(process-menu-key-event this e)
Handles a keystroke in a menu.
e - a MenuKeyEvent object - javax.swing.event.MenuKeyEvent
Handles a keystroke in a menu. e - a MenuKeyEvent object - `javax.swing.event.MenuKeyEvent`
(process-mouse-event this e path manager)
Processes a mouse event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using the MenuSelectionManager's API.
Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager.
e - a MouseEvent - java.awt.event.MouseEvent
path - the MenuElement path array - javax.swing.MenuElement[]
manager - the MenuSelectionManager - javax.swing.MenuSelectionManager
Processes a mouse event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using the MenuSelectionManager's API. Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager. e - a MouseEvent - `java.awt.event.MouseEvent` path - the MenuElement path array - `javax.swing.MenuElement[]` manager - the MenuSelectionManager - `javax.swing.MenuSelectionManager`
(remove-menu-drag-mouse-listener this l)
Removes a MenuDragMouseListener from the menu item.
l - the MenuDragMouseListener to be removed - javax.swing.event.MenuDragMouseListener
Removes a MenuDragMouseListener from the menu item. l - the MenuDragMouseListener to be removed - `javax.swing.event.MenuDragMouseListener`
(remove-menu-key-listener this l)
Removes a MenuKeyListener from the menu item.
l - the MenuKeyListener to be removed - javax.swing.event.MenuKeyListener
Removes a MenuKeyListener from the menu item. l - the MenuKeyListener to be removed - `javax.swing.event.MenuKeyListener`
(set-accelerator this key-stroke)
Sets the key combination which invokes the menu item's action listeners without navigating the menu hierarchy. It is the UI's responsibility to install the correct action. Note that when the keyboard accelerator is typed, it will work whether or not the menu is currently displayed.
key-stroke - the KeyStroke which will serve as an accelerator - javax.swing.KeyStroke
Sets the key combination which invokes the menu item's action listeners without navigating the menu hierarchy. It is the UI's responsibility to install the correct action. Note that when the keyboard accelerator is typed, it will work whether or not the menu is currently displayed. key-stroke - the KeyStroke which will serve as an accelerator - `javax.swing.KeyStroke`
(set-armed this b)
Identifies the menu item as "armed". If the mouse button is released while it is over this item, the menu's action event will fire. If the mouse button is released elsewhere, the event will not fire and the menu item will be disarmed.
b - true to arm the menu item so it can be selected - boolean
Identifies the menu item as "armed". If the mouse button is released while it is over this item, the menu's action event will fire. If the mouse button is released elsewhere, the event will not fire and the menu item will be disarmed. b - true to arm the menu item so it can be selected - `boolean`
(set-enabled this b)
Enables or disables the menu item.
b - true to enable the item - boolean
Enables or disables the menu item. b - true to enable the item - `boolean`
(set-model this new-model)
Sets the model that this button represents.
new-model - the new ButtonModel - javax.swing.ButtonModel
Sets the model that this button represents. new-model - the new ButtonModel - `javax.swing.ButtonModel`
(set-ui this ui)
Sets the look and feel object that renders this component.
ui - the JMenuItemUI L&F object - javax.swing.plaf.MenuItemUI
Sets the look and feel object that renders this component. ui - the JMenuItemUI L&F object - `javax.swing.plaf.MenuItemUI`
(update-ui this)
Resets the UI property with a value from the current look and feel.
Resets the UI property with a value from the current look and feel.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close