|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.ButtonGroup
public class ButtonGroup
此类用于为一组按钮创建一个多斥(multiple-exclusion)作用域。使用相同的 ButtonGroup 对象创建一组按钮意味着“开启”其中一个按钮时,将关闭组中的其他所有按钮。
可将 ButtonGroup 用于任何从 AbstractButton 继承的对象组。通常,按钮组包含 JRadioButton、JRadioButtonMenuItem 或 JToggleButton 的实例。但将 JButton 或 JMenuItem 的实例放入按钮组中并没有什么意义,因为 JButton 和 JMenuItem 不实现选择状态。
最初,组中的所有按钮都未被选择。
有关使用按钮组的示例和更多信息,请参阅 The Java Tutorial 中的 How to Radio Buttons 一节。
警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
| 字段摘要 | |
|---|---|
protected Vector<AbstractButton> |
buttons
|
| 构造方法摘要 | |
|---|---|
ButtonGroup()
创建一个新的 ButtonGroup。 |
|
| 方法摘要 | |
|---|---|
void |
add(AbstractButton b)
将按钮添加到组中。 |
void |
clearSelection()
清除选中内容,从而没有选择 ButtonGroup 中的任何按钮。 |
int |
getButtonCount()
返回此组中的按钮数。 |
Enumeration<AbstractButton> |
getElements()
返回此组中的所有按钮。 |
ButtonModel |
getSelection()
返回选择按钮的模型。 |
boolean |
isSelected(ButtonModel m)
返回对是否已选择一个 ButtonModel 的判断。 |
void |
remove(AbstractButton b)
从组中移除按钮。 |
void |
setSelected(ButtonModel m,
boolean b)
为 ButtonModel 设置选择值。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected Vector<AbstractButton> buttons
| 构造方法详细信息 |
|---|
public ButtonGroup()
ButtonGroup。
| 方法详细信息 |
|---|
public void add(AbstractButton b)
b - 要添加的按钮public void remove(AbstractButton b)
b - 要移除的按钮public void clearSelection()
ButtonGroup 中的任何按钮。
public Enumeration<AbstractButton> getElements()
Enumerationpublic ButtonModel getSelection()
public void setSelected(ButtonModel m,
boolean b)
ButtonModel 设置选择值。一次只能选择组中的一个按钮。
m - ButtonModelb - 如果此按钮被选择,则该参数为 true,否则为 falsepublic boolean isSelected(ButtonModel m)
ButtonModel 的判断。
true;否则返回 falsepublic int getButtonCount()
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。