- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.AbstractButton
-
- javax.swing.JMenuItem
-
- All Implemented Interfaces:
-
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中找到更多信息。有关进一步的文档和示例,请参阅Java教程中的 How to Use Menus 。
警告: Swing不是线程安全的。 欲了解更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4版本开始,所有JavaBeans的长期存储支持已被添加到
java.beans
软件包中。 请参阅XMLEncoder
。- 从以下版本开始:
- 1.2
- 另请参见:
-
JPopupMenu
,JMenu
,JCheckBoxMenuItem
,JRadioButtonMenuItem
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 protected class
JMenuItem.AccessibleJMenuItem
这个类实现JMenuItem
类的可访问性支持。-
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
-
Field Summary
-
Fields inherited from class 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
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from 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
-
-
构造方法摘要
构造方法 Constructor 描述 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
。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 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
setModel(ButtonModel newModel)
设置此按钮所代表的模型。void
setUI(MenuItemUI ui)
设置呈现此组件的外观和对象。void
updateUI()
将UI属性重新设置为来自当前外观的值。-
Methods inherited from class 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, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
-
Methods inherited from class 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, 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, 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
-
Methods inherited from class 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
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, 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, hide, 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
-
-
-
-
构造方法详细信息
-
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
-
-
方法详细信息
-
setModel
public void setModel(ButtonModel newModel)
设置此按钮所代表的模型。- 重写:
-
setModel
在AbstractButton
- 参数
-
newModel
- 新的ButtonModel
- 另请参见:
-
AbstractButton.getModel()
-
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
-JMenuItemUI
L&F对象 - 另请参见:
-
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
菜单项,以便它可以选择
-
isArmed
public boolean isArmed()
返回菜单项是否为“布防”。- 结果
- 如果菜单项已布防,则为真,并且可以选择该项
- 另请参见:
-
setArmed(boolean)
-
setEnabled
@BeanProperty(preferred=true, description="The enabled state of the component.") public void setEnabled(boolean b)
启用或禁用菜单项。- 重写:
-
setEnabled
在AbstractButton
- 参数
-
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
- aMenuDragMouseEvent
对象
-
processMenuKeyEvent
public void processMenuKeyEvent(MenuKeyEvent e)
在菜单中处理按键。- 参数
-
e
- aMenuKeyEvent
对象
-
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
的数组
-
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
- 结果
-
一个
AccessibleJMenuItem
,作为AccessibleContext
的这个JMenuItem
-
-