- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.AbstractButton
-
- javax.swing.JMenuItem
-
- 实现的所有接口
-
ImageObserver
,ItemSelectable
,MenuContainer
,Serializable
,Accessible
,MenuElement
,SwingConstants
- 已知直接子类:
-
JCheckBoxMenuItem
,JMenu
,JRadioButtonMenuItem
@JavaBean(defaultProperty="UIClassID", description="An item which can be selected in a menu.") public class JMenuItem extends AbstractButton implements Accessible, MenuElement
菜单中项目的实现。 菜单项本质上是位于列表中的按钮。 当用户选择“按钮”时,执行与菜单项相关联的动作。JMenuItem
包含的JPopupMenu
正好执行该功能。可以通过
Action
s配置菜单项,并在某种程度上控制。 将Action
与菜单项一起使用除了直接配置菜单项外,还有许多其他好处。 有关更多详细信息,请参阅Swing Components SupportingAction
,您可以在“Java教程”的 How to Use Actions部分中找到更多信息。有关更多文档和示例,请参阅The Java Tutorial中的 How to Use Menus 。
警告: Swing不是线程安全的。 有关更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans
软件包中添加了对所有JavaBeansjava.beans
长期存储的支持。 请参阅XMLEncoder
。- 从以下版本开始:
- 1.2
- 另请参见:
-
JPopupMenu
,JMenu
,JCheckBoxMenuItem
,JRadioButtonMenuItem
, Serialized Form
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 protected class
JMenuItem.AccessibleJMenuItem
此类实现JMenuItem
类的可访问性支持。-
嵌套类/接口声明在类 javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
-
嵌套类/接口声明在类 javax.swing.JComponent
JComponent.AccessibleJComponent
-
嵌套类/接口声明在类 java.awt.Container
Container.AccessibleAWTContainer
-
-
字段汇总
-
声明的属性在类 javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
-
声明的属性在类 javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
声明的属性在类 java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields declared in interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
-
构造方法摘要
构造方法 构造器 描述 JMenuItem()
创建一个没有设置文本或图标的JMenuItem
。JMenuItem(String text)
使用指定的文本创建JMenuItem
。JMenuItem(String text, int mnemonic)
使用指定的文本和键盘助记符创建JMenuItem
。JMenuItem(String text, Icon icon)
使用指定的文本和图标创建JMenuItem
。JMenuItem(Action a)
创建一个菜单项,其属性取自指定的Action
。JMenuItem(Icon icon)
使用指定的图标创建JMenuItem
。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 protected void
actionPropertyChanged(Action action, String propertyName)
更新按钮的状态以响应相关操作中的属性更改。void
addMenuDragMouseListener(MenuDragMouseListener l)
将MenuDragMouseListener
添加到菜单项。void
addMenuKeyListener(MenuKeyListener l)
将MenuKeyListener
添加到菜单项。protected void
configurePropertiesFromAction(Action a)
设置此按钮上的属性以匹配指定的Action
中的Action
。protected void
fireMenuDragMouseDragged(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。protected void
fireMenuDragMouseEntered(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。protected void
fireMenuDragMouseExited(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。protected void
fireMenuDragMouseReleased(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。protected void
fireMenuKeyPressed(MenuKeyEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。protected void
fireMenuKeyReleased(MenuKeyEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。protected void
fireMenuKeyTyped(MenuKeyEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。KeyStroke
getAccelerator()
返回KeyStroke
,它用作菜单项的加速器。AccessibleContext
getAccessibleContext()
返回与AccessibleContext
相关联的JMenuItem
。Component
getComponent()
返回用于绘制此对象的java.awt.Component
。MenuDragMouseListener[]
getMenuDragMouseListeners()
返回使用addMenuDragMouseListener()添加到此JMenuItem的所有MenuDragMouseListener
的数组。MenuKeyListener[]
getMenuKeyListeners()
返回使用addMenuKeyListener()添加到此JMenuItem的所有MenuKeyListener
的数组。MenuElement[]
getSubElements()
此方法返回一个包含此菜单组件的子菜单组件的数组。String
getUIClassID()
返回用于构造用于呈现此组件的L&F类名称的后缀。protected void
init(String text, Icon icon)
使用指定的文本和图标初始化菜单项。boolean
isArmed()
返回菜单项是否“已布防”。void
menuSelectionChanged(boolean isIncluded)
选择或取消选择MenuSelectionManager
时由MenuElement
调用。protected String
paramString()
返回此JMenuItem
的字符串表示JMenuItem
。void
processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
处理从MenuSelectionManager
转发的键事件,并根据需要使用MenuSelectionManager
的API更改菜单选择。void
processMenuDragMouseEvent(MenuDragMouseEvent e)
在菜单中处理鼠标拖动。void
processMenuKeyEvent(MenuKeyEvent e)
处理菜单中的击键。void
processMouseEvent(MouseEvent e, MenuElement[] path, MenuSelectionManager manager)
处理从MenuSelectionManager
转发的鼠标事件,并根据需要使用MenuSelectionManager
的API更改菜单选项。void
removeMenuDragMouseListener(MenuDragMouseListener l)
从菜单项中删除MenuDragMouseListener
。void
removeMenuKeyListener(MenuKeyListener l)
从菜单项中删除MenuKeyListener
。void
setAccelerator(KeyStroke keyStroke)
设置调用菜单项的动作侦听器的组合键,而不导航菜单层次结构。void
setArmed(boolean b)
将菜单项标识为“已布防”。void
setEnabled(boolean b)
启用或禁用菜单项。void
setUI(MenuItemUI ui)
设置呈现此组件的外观对象。void
updateUI()
使用当前外观中的值重置UI属性。-
声明方法的类 javax.swing.AbstractButton
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
-
声明方法的类 javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
声明方法的类 java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
-
声明方法的类 java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
构造方法详细信息
-
JMenuItem
public JMenuItem()
创建没有设置文本或图标的JMenuItem
。
-
JMenuItem
public JMenuItem(Icon icon)
使用指定的图标创建JMenuItem
。- 参数
-
icon
-的图标JMenuItem
-
JMenuItem
public JMenuItem(String text)
创建具有指定文本的JMenuItem
。- 参数
-
text
-该文JMenuItem
-
JMenuItem
public JMenuItem(Action a)
创建一个菜单项,其属性取自指定的Action
。- 参数
-
a
-的的作用JMenuItem
- 从以下版本开始:
- 1.3
-
JMenuItem
public JMenuItem(String text, Icon icon)
使用指定的文本和图标创建JMenuItem
。- 参数
-
text
-该文JMenuItem
-
icon
-的图标JMenuItem
-
JMenuItem
public JMenuItem(String text, int mnemonic)
使用指定的文本和键盘助记符创建JMenuItem
。- 参数
-
text
-该文JMenuItem
-
mnemonic
-键盘助记符JMenuItem
-
-
方法详细信息
-
init
protected void init(String text, Icon icon)
使用指定的文本和图标初始化菜单项。- 重写:
-
init
,类AbstractButton
- 参数
-
text
-该文JMenuItem
-
icon
-的图标JMenuItem
-
setUI
@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the LookAndFeel.") public void setUI(MenuItemUI ui)
设置呈现此组件的外观对象。- 参数
-
ui
- L&F对象的JMenuItemUI
- 另请参见:
-
UIDefaults.getUI(javax.swing.JComponent)
-
updateUI
public void updateUI()
使用当前外观中的值重置UI属性。- 重写:
-
updateUI
在类AbstractButton
- 另请参见:
-
JComponent.updateUI()
-
getUIClassID
@BeanProperty(bound=false) public String getUIClassID()
返回用于构造用于呈现此组件的L&F类名称的后缀。- 重写:
-
getUIClassID
类JComponent
- 结果
- 字符串“MenuItemUI”
- 另请参见:
-
JComponent.getUIClassID()
,UIDefaults.getUI(javax.swing.JComponent)
-
setArmed
@BeanProperty(bound=false, hidden=true, description="Mouse release will fire an action event") public void setArmed(boolean b)
将菜单项标识为“已布防”。 如果在此项目上方释放鼠标按钮,则会触发菜单的操作事件。 如果在其他地方释放鼠标按钮,则不会触发事件并且撤消菜单项。- 参数
-
b
- 如果可以选择菜单项,b
true
-
isArmed
public boolean isArmed()
返回菜单项是否“已布防”。- 结果
- 如果菜单项已布防,则为true,并且可以选择该菜单项
- 另请参见:
-
setArmed(boolean)
-
setEnabled
@BeanProperty(preferred=true, description="The enabled state of the component.") public void setEnabled(boolean b)
启用或禁用菜单项。- 重写:
-
setEnabled
在类AbstractButton
- 参数
-
b
- 如果启用该项,b
true - 另请参见:
-
Component.isEnabled()
,Component.isLightweight()
-
setAccelerator
@BeanProperty(preferred=true, description="The keystroke combination which will invoke the JMenuItem\'s actionlisteners without navigating the menu hierarchy") public void setAccelerator(KeyStroke keyStroke)
设置调用菜单项的动作侦听器的组合键,而不导航菜单层次结构。 UI负责安装正确的操作。 请注意,键入键盘加速键时,无论当前是否显示菜单,它都将起作用。- 参数
-
keyStroke
-KeyStroke
将作为加速器
-
getAccelerator
public KeyStroke getAccelerator()
返回KeyStroke
,它用作菜单项的加速器。- 结果
-
标识加速键的
KeyStroke
对象
-
configurePropertiesFromAction
protected void configurePropertiesFromAction(Action a)
设置此按钮上的属性以匹配指定的Action
中的Action
。 有关此设置的属性的详细信息,请参阅Swing Components SupportingAction
。- 重写:
-
configurePropertiesFromAction
在类AbstractButton
- 参数
-
a
-Action
获取房产的null
,或null
- 从以下版本开始:
- 1.3
- 另请参见:
-
Action
,AbstractButton.setAction(javax.swing.Action)
-
actionPropertyChanged
protected void actionPropertyChanged(Action action, String propertyName)
更新按钮的状态以响应相关操作中的属性更改。 从PropertyChangeListener
返回的createActionPropertyChangeListener
调用此方法。 子类通常不需要调用它。 支持其他Action
属性的子类应覆盖此属性和configurePropertiesFromAction
。有关此方法设置的属性列表,请参阅表Swing Components Supporting
Action
。- 重写:
-
actionPropertyChanged
类AbstractButton
- 参数
-
action
- 与此按钮关联的Action
-
propertyName
- 已更改的属性的名称 - 从以下版本开始:
- 1.6
- 另请参见:
-
Action
,AbstractButton.configurePropertiesFromAction(javax.swing.Action)
-
processMouseEvent
public void processMouseEvent(MouseEvent e, MenuElement[] path, MenuSelectionManager manager)
处理从MenuSelectionManager
转发的鼠标事件,并根据需要使用MenuSelectionManager
的API更改菜单选项。注意:您不必将事件转发给子组件。 这由
MenuSelectionManager
自动完成。- Specified by:
-
processMouseEvent
,界面MenuElement
- 参数
-
e
- aMouseEvent
-
path
-MenuElement
路径数组 -
manager
-MenuSelectionManager
-
processKeyEvent
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
处理从MenuSelectionManager
转发的键事件,并根据需要使用MenuSelectionManager
的API更改菜单选择。注意:您不必将事件转发给子组件。 这由
MenuSelectionManager
自动完成。- Specified by:
-
processKeyEvent
在界面MenuElement
- 参数
-
e
- aKeyEvent
-
path
-MenuElement
路径数组 -
manager
-MenuSelectionManager
-
processMenuDragMouseEvent
public void processMenuDragMouseEvent(MenuDragMouseEvent e)
在菜单中处理鼠标拖动。- 参数
-
e
- 一个MenuDragMouseEvent
对象
-
processMenuKeyEvent
public void processMenuKeyEvent(MenuKeyEvent e)
处理菜单中的击键。- 参数
-
e
- 一个MenuKeyEvent
对象
-
fireMenuDragMouseEntered
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuMouseDragEvent
- 另请参见:
-
EventListenerList
-
fireMenuDragMouseExited
protected void fireMenuDragMouseExited(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuDragMouseEvent
- 另请参见:
-
EventListenerList
-
fireMenuDragMouseDragged
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuDragMouseEvent
- 另请参见:
-
EventListenerList
-
fireMenuDragMouseReleased
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuDragMouseEvent
- 另请参见:
-
EventListenerList
-
fireMenuKeyPressed
protected void fireMenuKeyPressed(MenuKeyEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuKeyEvent
- 另请参见:
-
EventListenerList
-
fireMenuKeyReleased
protected void fireMenuKeyReleased(MenuKeyEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuKeyEvent
- 另请参见:
-
EventListenerList
-
fireMenuKeyTyped
protected void fireMenuKeyTyped(MenuKeyEvent event)
通知所有已注册对此事件类型的通知感兴趣的听众。- 参数
-
event
- aMenuKeyEvent
- 另请参见:
-
EventListenerList
-
menuSelectionChanged
public void menuSelectionChanged(boolean isIncluded)
选择或取消选择MenuSelectionManager
时由MenuElement
调用。- Specified by:
-
menuSelectionChanged
,界面MenuElement
- 参数
-
isIncluded
- 如果此菜单项位于更改的菜单路径部分,isIncluded
true;如果此菜单是更改的菜单路径的一部分,则为false,但该路径的此特定部分仍然相同 - 另请参见:
-
MenuSelectionManager.setSelectedPath(MenuElement[])
-
getSubElements
@BeanProperty(bound=false) public MenuElement[] getSubElements()
此方法返回一个包含此菜单组件的子菜单组件的数组。- Specified by:
-
getSubElements
在接口MenuElement
- 结果
-
数组
MenuElement
s
-
getComponent
public Component getComponent()
返回用于绘制此对象的java.awt.Component
。 返回的组件将用于转换事件并检测事件是否在菜单组件内。- Specified by:
-
getComponent
,界面MenuElement
- 结果
-
绘制此菜单项的
Component
-
addMenuDragMouseListener
public void addMenuDragMouseListener(MenuDragMouseListener l)
将MenuDragMouseListener
添加到菜单项。- 参数
-
l
- 要添加的MenuDragMouseListener
-
removeMenuDragMouseListener
public void removeMenuDragMouseListener(MenuDragMouseListener l)
从菜单项中删除MenuDragMouseListener
。- 参数
-
l
- 要删除的MenuDragMouseListener
-
getMenuDragMouseListeners
@BeanProperty(bound=false) public MenuDragMouseListener[] getMenuDragMouseListeners()
返回使用addMenuDragMouseListener()添加到此JMenuItem的所有MenuDragMouseListener
的数组。- 结果
-
如果没有添加任何侦听器,则添加所有
MenuDragMouseListener
或空数组 - 从以下版本开始:
- 1.4
-
addMenuKeyListener
public void addMenuKeyListener(MenuKeyListener l)
将MenuKeyListener
添加到菜单项。- 参数
-
l
- 要添加的MenuKeyListener
-
removeMenuKeyListener
public void removeMenuKeyListener(MenuKeyListener l)
从菜单项中删除MenuKeyListener
。- 参数
-
l
- 要删除的MenuKeyListener
-
getMenuKeyListeners
@BeanProperty(bound=false) public MenuKeyListener[] getMenuKeyListeners()
返回使用addMenuKeyListener()添加到此JMenuItem的所有MenuKeyListener
的数组。- 结果
-
添加了所有
MenuKeyListener
如果没有添加侦听器,则为空数组 - 从以下版本开始:
- 1.4
-
paramString
protected String paramString()
返回此JMenuItem
的字符串表示JMenuItem
。 此方法仅用于调试目的,返回字符串的内容和格式可能因实现而异。 返回的字符串可能为空,但可能不是null
。- 重写:
-
paramString
,类AbstractButton
- 结果
-
此
JMenuItem
的字符串表示JMenuItem
-
getAccessibleContext
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()
返回与AccessibleContext
关联的JMenuItem
。 为JMenuItem
s时,AccessibleContext
需要一个的形式AccessibleJMenuItem
。 如有必要,将创建一个新的AccessibleJMenuItme实例。- Specified by:
-
getAccessibleContext
在界面Accessible
- 重写:
-
getAccessibleContext
类Component
- 结果
-
an
AccessibleJMenuItem
that serves as theAccessibleContext
of thisJMenuItem
-
-