public class ButtonGroup extends Object implements Serializable
ButtonGroupobject means that turning "on" one of those buttons turns off all other buttons in the group.
ButtonGroup can be used with
any set of objects that inherit from
Typically a button group contains instances of
It wouldn't make sense to put an instance of
in a button group
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.
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 JavaBeansTM
has been added to the
|Modifier and Type||Field and Description|
|Constructor and Description|
Creates a new
|Modifier and Type||Method and Description|
Adds the button to the group.
Clears the selection such that none of the buttons in the
Returns the number of buttons in the group.
Returns all the buttons that are participating in this group.
Returns the model of the selected button.
Returns whether a
Removes the button from the group.
Sets the selected value for the
public void add(AbstractButton b)
b- the button to be added
public void remove(AbstractButton b)
b- the button to be removed
public void clearSelection()
public Enumeration<AbstractButton> getElements()
Enumerationof the buttons in this group
public ButtonModel getSelection()
public void setSelected(ButtonModel m, boolean b)
ButtonModel. Only one button in the group may be selected at a time.
trueif this button is to be selected, otherwise
public boolean isSelected(ButtonModel m)
trueif the button is selected, otherwise returns
public int getButtonCount()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.