ButtonGroup object means that
turning "on" one of those buttons
turns off all other buttons in the group.
A ButtonGroup can be used with
any set of objects that inherit from AbstractButton.
Typically a button group contains instances of
JRadioButton,
JRadioButtonMenuItem,
or JToggleButton.
It wouldn't make sense to put an instance of
JButton or JMenuItem
in a button group
because JButton and JMenuItem
don't implement the selected state.
Initially, all buttons in the group are unselected.
For examples and further information on using button groups see How to Use Radio Buttons, a section in The Java Tutorial.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Field and Description |
|---|---|
| protected Vector | buttons
The list of buttons participating in this group. |
| pack-priv ButtonModel | selection
The current selection. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public int | |
| public Enumeration | Returns: anEnumeration of the buttons in this groupReturns all the buttons that are participating in this group. |
| public ButtonModel | |
| public boolean | Returns: true if the button is selected,
otherwise returns falsean instance of m)ButtonModelReturns whether a |
| public void | |
| public void | setSelected(ButtonModel
the m, boolean ButtonModeltrue if this button is to be
selected, otherwise falseSets the selected value for the |
| buttons | back to summary |
|---|---|
| protected Vector<AbstractButton> buttons The list of buttons participating in this group. | |
| selection | back to summary |
|---|---|
| pack-priv ButtonModel selection The current selection. | |
| ButtonGroup | back to summary |
|---|---|
| public ButtonGroup() Creates a new | |
| add | back to summary |
|---|---|
| public void add(AbstractButton b) Adds the button to the group.
| |
| clearSelection | back to summary |
|---|---|
| public void clearSelection() Clears the selection such that none of the buttons
in the
| |
| getButtonCount | back to summary |
|---|---|
| public int getButtonCount() Returns the number of buttons in the group.
| |
| getElements | back to summary |
|---|---|
| public Enumeration Returns all the buttons that are participating in this group.
| |
| getSelection | back to summary |
|---|---|
| public ButtonModel getSelection() Returns the model of the selected button.
| |
| isSelected | back to summary |
|---|---|
| public boolean isSelected(ButtonModel m) Returns whether a
| |
| remove | back to summary |
|---|---|
| public void remove(AbstractButton b) Removes the button from the group.
| |
| setSelected | back to summary |
|---|---|
| public void setSelected(ButtonModel m, boolean b) Sets the selected value for the
| |