|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.ButtonGroup
public class ButtonGroup
Logically groups a set of buttons, so that only one of the buttons in
a ButtonGroup can be selected at the same time. If one
button in a ButtonGroup is selected, all other buttons
are automatically deselected.
While ButtonGroup can be used for all buttons that are derived
from AbstractButton, it is normally only used for
JRadioButtons, JRadioButtonMenuItems and
JToggleButtons.
You could use it for JCheckBoxes, but for the sake of usability
this is strongly discouraged because the common expectation of checkboxes
is that the user is allowed to make multiple selections.
It makes no sense to put JButtons or JMenuItems in
a ButtonGroup because they don't implement the
selected semantics.
| Field Summary | |
|---|---|
protected Vector<AbstractButton> |
buttons
Stores references to the buttons added to this button group. |
| Constructor Summary | |
|---|---|
ButtonGroup()
Creates a new button group. |
|
| Method Summary | |
|---|---|
void |
add(AbstractButton b)
Adds a button to this group. |
int |
getButtonCount()
Return the number of buttons in this button group. |
Enumeration<AbstractButton> |
getElements()
Returns the currently added buttons. |
ButtonModel |
getSelection()
Returns the currently selected button model. |
boolean |
isSelected(ButtonModel m)
Checks if the given ButtonModel is selected in this button
group. |
void |
remove(AbstractButton b)
Removes the specified button from this group. |
void |
setSelected(ButtonModel m,
boolean b)
Sets the currently selected button model. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Vector<AbstractButton> buttons
| Constructor Detail |
|---|
public ButtonGroup()
| Method Detail |
|---|
public void add(AbstractButton b)
b - the button to add (null is ignored).public void remove(AbstractButton b)
null.
The group for the removed button's model is set to null.
b - the button to remove (null is ignored).public Enumeration<AbstractButton> getElements()
Enumeration over all added buttonspublic ButtonModel getSelection()
public void setSelected(ButtonModel m,
boolean b)
m - the model to selectb - true if this button is to be selected, false otherwisepublic boolean isSelected(ButtonModel m)
ButtonModel is selected in this button
group.
m - the button model (null permitted).
true if m is the selected button model
in this group, and false otherwise.public int getButtonCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||