- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.AbstractButton
-
- javax.swing.JMenuItem
-
- javax.swing.JRadioButtonMenuItem
-
- All Implemented Interfaces:
-
ImageObserver
,ItemSelectable
,MenuContainer
,Serializable
,Accessible
,MenuElement
,SwingConstants
@JavaBean(description="A component within a group of menu items which can be selected.") public class JRadioButtonMenuItem extends JMenuItem implements Accessible
单选按钮菜单项的实现。 AJRadioButtonMenuItem
是菜单项,它是一组菜单项的一部分,其中只能选择组中的一个项目。 所选项显示其所选状态。 选择它将导致任何其他所选项目切换到未选择的状态。 要控制一组单选按钮菜单项的选定状态,请使用ButtonGroup
对象。菜单项可以配置,并在一定程度上由
Action
秒控制。 使用带有菜单项的Action
除了直接配置菜单项之外,还有很多好处。 有关详细信息,请参阅Swing Components SupportingAction
,您可以在“Java教程”一节中的 How to Use Actions中找到更多信息。一些菜单可以有多个按钮组,其中包含单选按钮菜单项。 在这种情况下,单击一个单选按钮菜单项不会关闭菜单是有用的。 这种行为可以通过客户端进行控制或者
JComponent.putClientProperty(java.lang.Object, java.lang.Object)
或外观及感觉UIManager.put(java.lang.Object, java.lang.Object)
命名属性"RadioButtonMenuItem.doNotCloseOnMouseClick"
。 默认值为false
。 将属性设置为true
可防止菜单在鼠标单击时关闭。 如果客户端属性被设置,它的值始终被使用; 否则L&F属性被查询。 注意:一些L&F
可能会忽略此属性。 所有内置的L&F
都继承了这种行为。有关进一步的文档和示例,请参阅“Java教程”中的“ How to Use Menus ”一节。
警告: Swing不是线程安全的。 有关更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4版本开始,所有JavaBeans的长期存储支持已被添加到
java.beans
软件包中。 请参阅XMLEncoder
。- 从以下版本开始:
- 1.2
- 另请参见:
-
ButtonGroup
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 protected class
JRadioButtonMenuItem.AccessibleJRadioButtonMenuItem
该类实现JRadioButtonMenuItem
类的可访问性支持。-
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
-
Nested classes/interfaces inherited from class javax.swing.JMenuItem
JMenuItem.AccessibleJMenuItem
-
-
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 描述 JRadioButtonMenuItem()
创建一个没有设置文本或图标的JRadioButtonMenuItem
。JRadioButtonMenuItem(String text)
创建一个JRadioButtonMenuItem
与文本。JRadioButtonMenuItem(String text, boolean selected)
创建具有指定文本和选择状态的单选按钮菜单项。JRadioButtonMenuItem(String text, Icon icon)
创建具有指定文本的单选按钮菜单项和Icon
。JRadioButtonMenuItem(String text, Icon icon, boolean selected)
创建具有指定文本,图像和选择状态的单选按钮菜单项。JRadioButtonMenuItem(Action a)
创建一个单选按钮菜单项,其属性取自提供的Action
。JRadioButtonMenuItem(Icon icon)
创建一个带有图标的JRadioButtonMenuItem
。JRadioButtonMenuItem(Icon icon, boolean selected)
创建具有指定图像和选择状态但无文字的单选按钮菜单项。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 AccessibleContext
getAccessibleContext()
获取与此JRadioButtonMenuItem关联的AccessibleContext。String
getUIClassID()
返回呈现此组件的L&F类的名称。protected String
paramString()
返回此JRadioButtonMenuItem
的字符串表示JRadioButtonMenuItem
。-
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
-
Methods inherited from class javax.swing.JMenuItem
actionPropertyChanged, addMenuDragMouseListener, addMenuKeyListener, configurePropertiesFromAction, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, getComponent, getMenuDragMouseListeners, getMenuKeyListeners, getSubElements, init, isArmed, menuSelectionChanged, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setAccelerator, setArmed, setEnabled, setModel, setUI, updateUI
-
-
-
-
构造方法详细信息
-
JRadioButtonMenuItem
public JRadioButtonMenuItem()
创建一个没有设置文本或图标的JRadioButtonMenuItem
。
-
JRadioButtonMenuItem
public JRadioButtonMenuItem(Icon icon)
创建一个带有图标的JRadioButtonMenuItem
。- 参数
-
icon
-所述Icon
以显示在JRadioButtonMenuItem
-
JRadioButtonMenuItem
public JRadioButtonMenuItem(String text)
创建一个JRadioButtonMenuItem
与文本。- 参数
-
text
-该文JRadioButtonMenuItem
-
JRadioButtonMenuItem
public JRadioButtonMenuItem(Action a)
创建一个单选按钮菜单项,其属性取自提供的Action
。- 参数
-
a
- 基于单选按钮菜单项的Action
- 从以下版本开始:
- 1.3
-
JRadioButtonMenuItem
public JRadioButtonMenuItem(String text, Icon icon)
创建具有指定文本的单选按钮菜单项和Icon
。- 参数
-
text
- 文字JRadioButtonMenuItem
-
icon
-以显示在该图标JRadioButtonMenuItem
-
JRadioButtonMenuItem
public JRadioButtonMenuItem(String text, boolean selected)
创建具有指定文本和选择状态的单选按钮菜单项。- 参数
-
text
-该文CheckBoxMenuItem
-
selected
- 选定的状态为CheckBoxMenuItem
-
JRadioButtonMenuItem
public JRadioButtonMenuItem(Icon icon, boolean selected)
创建具有指定图像和选择状态但无文字的单选按钮菜单项。- 参数
-
icon
- 按钮应该显示的图像 -
selected
- 如果为真,则初始选择该按钮; 否则,该按钮最初未被选择
-
-
方法详细信息
-
getUIClassID
@BeanProperty(bound=false) public String getUIClassID()
返回呈现此组件的L&F类的名称。- 重写:
-
getUIClassID
在JMenuItem
- 结果
- 字符串“RadioButtonMenuItemUI”
- 另请参见:
-
JComponent.getUIClassID()
,UIDefaults.getUI(javax.swing.JComponent)
-
paramString
protected String paramString()
返回此JRadioButtonMenuItem
的字符串表示JRadioButtonMenuItem
。 该方法仅用于调试目的,并且返回的字符串的内容和格式可能因实现而异。 返回的字符串可能为空,但可能不是null
。- 重写:
-
paramString
中的JMenuItem
- 结果
-
这个
JRadioButtonMenuItem
的字符串表示JRadioButtonMenuItem
-
getAccessibleContext
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()
获取与此JRadioButtonMenuItem关联的AccessibleContext。 对于JRadioButtonMenuItems,AccessibleContext采用AccessibleJRadioButtonMenuItem的形式。 如有必要,将创建一个新的AccessibleJRadioButtonMenuItem实例。- Specified by:
-
getAccessibleContext
在接口Accessible
- 重写:
-
getAccessibleContext
在JMenuItem
- 结果
- 一个AccessibleJRadioButtonMenuItem,用作这个JRadioButtonMenuItem的AccessibleContext
-
-