|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。