简单JRadioButton用法.docx
- 文档编号:27429678
- 上传时间:2023-06-30
- 格式:DOCX
- 页数:12
- 大小:19.49KB
简单JRadioButton用法.docx
《简单JRadioButton用法.docx》由会员分享,可在线阅读,更多相关《简单JRadioButton用法.docx(12页珍藏版)》请在冰豆网上搜索。
简单JRadioButton用法
javax.swing
类JRadioButton
java.lang.Object
I-Ijava.awt.Component
I—java.awt.Container
I-Ijavax.swing.JComponent
I—javax.swing.AbstractButton
I-Ijavax.swing.JToggleButton
I—javax.swing.JRadioButton
所有已实现的接口:
ImageObserver,ItemSelectable,MenuContainer,Serializable,Accessible,SwingConstants
publicclassJRadioButton
extendsJToggleButtonimplementsAccessible
实现一个单选按钮,此按钮项可被选择或取消选择,并可为用户显示其状态。
与ButtonGroup对象
配合使用可创建一组按钮,一次只能选择其中的一个按钮。
(创建一个ButtonGroup对象并用其add
方法将JRadioButton对象包含在此组中。
)
注:
ButtonGroup对象为逻辑分组,不是物理分组。
要创建按钮面板,仍需要创建一个JPanel或类似
的容器对象并将Border添加到其中以便将面板与周围的组件分开。
通过Action可以配置按钮,并进行一定程度的控制。
对按钮使用Action有许多直接配置按钮
所不及的优点。
有关更多信息,请参阅支持Action的Swing组件,可以在TheJavaTutorial中的
HowtoUseActions一节找到更多信息。
有关更多内容,请参阅TheJavaTutorial中的HowtoUseButtons,CheckBoxes,andRadio
Buttons。
警告:
Swing不是线程安全的。
有关更多信息,请参阅Swing'sThreadingPolicy。
警告:
此类的序列化对象与以后的Swing版本不兼容。
当前序列化支持适用于短期存储,或适用
于在运行相同Swing版本的应用程序之间进行RMI(RemoteMethodInvocation,远程方法调用)。
从
1.4版本开始,已在java.beans包中添加了支持所有JavaBeansTM长期存储的功能。
请参见
XMLEncoder。
另请参见:
ButtonGroup,JCheckBox
嵌套类摘要
protectedclassJRadioButton.AccessibleJRadioButton
此类实现对JRadioButton类的可访问性支持。
JToggleButton.AccessibleJToggleButton,
JToggleButton.ToggleButtonModel
从类javax.swing.AbstractButton继承的嵌套类/接口
AbstractButton.AccessibleAbstractButton,AbstractButton.ButtonChangeListener
从类javax.swing.JComponent继承的嵌套类/接口
JComponent.AccessibleJComponent
从类java.awt.Container继承的嵌套类/接口
Container.AccessibleAWTContainer
从类java.awt.Component继承的嵌套类/接口
Component.AccessibleAWTComponent,Component.BaselineResizeBehavior,
Component.BItBufferStrategy,Component.FlipBufferStrategy
字段摘要
从类javax.swing.AbstractButton继承的字段
ERTY,
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_PROPmodel,MODEL_CHANGED_PROPERTY,PRESSED_ICON_CHANGED_PROPERTY,ROLLOVER_ENABLED_CHANGED_PROPERTY,ROLLOVER_ICON_CHANGED_PROPERTY,ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY,
SELECTEDICONCHANGEDPROPERTY,TEXTCHANGEDPROPERTY,
VERTICAL_ALIGNMENT_CHANGED_PROPERTY,VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
从类javax.swing.JComponent继承的字段
accessibleContext,listenerList,TOOL_TIP_TEXT_KEY,ui,UNDEFINED_CONDITION,WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,WHEN_FOCUSED,WHEN_IN_FOCUSED_WINDOW
从类java.awt.Component继承的字段
BOTTOM_ALIGNMENT,CENTER_ALIGNMENT,LEFT_ALIGNMENT,RIGHT_ALGNMENT,TOP_ALIGNMENT
从接口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
从接口java.awt.image」mageObserver继承的字段
ABORT,ALLBITS,ERROR,FRAMEBITS,HEIGHT,PROPERTIES,SOMEBITS,WIDTH
构造方法摘要
JRadioButton()
创建一个初始化为未选择的单选按钮,其文本未设定。
JRadioButton(Actiona)
创建一个单选按钮,其属性来自提供的Action。
JRadioButton(Iconicon)
创建一个初始化为未选择的单选按钮,其具有指定的图像但无文本。
JRadioButton(Iconicon,booleanselected)创建一个具有指定图像和选择状态的单选按钮,但无文本。
JRadioButton(Stringtext)
创建一个具有指定文本的状态为未选择的单选按钮。
JRadioButton(Stringtext,booleanselected)
创建一个具有指定文本和选择状态的单选按钮。
JRadioButton(Stringtext,Iconicon)
创建一个具有指定的文本和图像并初始化为未选择的单选按钮。
JRadioButton(Stringtext,Iconicon,booleanselected)
创建一个具有指定的文本、图像和选择状态的单选按钮。
方法摘要
AccessibleContext
getAccessibleContext()
获取与此JRadioButton相关联的AccessibleContext。
String
getUIClassID()
返回呈现此组件的L&F类的名称。
protectedString
paramString()
返回此JRadioButton的字符串表示形式。
void
updateUI()
将UI属性重置为当前外观对应的值。
从类javax.swing.AbstractButton继承的方法
actionPropertyChanged,addActionListener,addChangeListener,addImpl,addItemListener,checkHorizontalKey,checkVerticalKey,configurePropertiesFromAction,createActionListener,createActionPropertyChangeListener,createChangeListener,createItemListener,doClick,doClick,fireActionPerformed,fireItemStateChanged,fireStateChanged,getAction,getActionCommand,getActionListeners,getChangeListeners,getDisabledIcon,getDisabledSelectedIcon,getDisplayedMnemonic"dex,getHideActionText,getHorizontalAlignment,getHorizontalTextPosition,getIcon,getIconTextGap,getItemListeners,getLabel,getMargin,getMnemonic,getModel,getMultiClickThreshhold,getPressedIcon,getRolloverIcon,getRolloverSelectedIcon,getSelectedIcon,getSelectedObjects,getText,getUI,getVerticalAlignment,getVerticalTextPosition,imageUpdate,init,isBorderPainted,isContentAreaFilled,isFocusPainted,isRolloverEnabled,isSelected,paintBorder,removeActionListener,removeChangeListener,removeltemListener,removeNotify,setAction,setActionCommand,setBorderPainted,setContentAreaFilled,setDisabledIcon,setDisabledSelectedIcon,setDisplayedMnemonic"dex,setEnabled,setFocusPainted,
setHideActionText,setHorizontalAlignment,setHorizontalTextPosition,setIcon,setIconTextGap,setLabel,setLayout,setMargin,setMnemonic,setMnemonic,setModel,setMultiClickThreshhold,setPressedIcon,setRolloverEnabled,setRolloverlcon,setRolloverSelectedlcon,setSelected,setSelectedIcon,setText,setUI,setVerticalAlignment,setVerticalTextPosition
从类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,isDoubleBuffered,isLightweightComponent,isManagingFocus,isOpaque,isOptimizedDrawingEnabled,isPaintingForPrint,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,transferFocusBackward,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,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,getMousePosit
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 JRadioButton 用法