public class ButtonGroup
extends java.lang.Object
This class is used to create a multiple-exclusion scope for a set of buttons. Creating a set of buttons with the
same ButtonGroup
object means that turning "on" one of those buttons turns off all other buttons in
the group.
Initially, all buttons in the group are unselected. Once any button is selected, one button is always selected in the group. There is no way to turn a button programmatically to "off", in order to clear the button group.
Constructor and Description |
---|
ButtonGroup()
Creates a new
ButtonGroup . |
Modifier and Type | Method and Description |
---|---|
void |
add(Button button)
Adds the button to the group.
|
void |
addButtonSelectionChangedListener(ButtonSelectionChangedListener listener)
Adds a listener for this group.
|
void |
buttonSelected(Button button)
Sets/unsets the selected value for the
Button . |
void |
buttonSelected(Button button,
boolean fireActionEvent)
Sets/unsets the selected value for the
Button . |
Button |
getSelection()
Returns the selected button;
null if none. |
void |
remove(Button button)
Removes the button from the group.
|
void |
removeAll()
Removes all buttons from the group.
|
public void addButtonSelectionChangedListener(ButtonSelectionChangedListener listener)
listener
- public void add(Button button)
button
- the button to be addedpublic void removeAll()
public void remove(Button button)
button
- the button to be removedpublic void buttonSelected(Button button)
Button
.
Only one button in the group may be selected at a time.button
- the Button
public void buttonSelected(Button button, boolean fireActionEvent)
Button
.
Only one button in the group may be selected at a time.button
- the Button
fireActionEvent
- do we fire the ActionEvent associated with this buttonpublic Button getSelection()
null
if none.