| Package | org.aswing |
| Class | public class ButtonGroup |
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. 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. To give the appearance of "none selected", add an invisible radio button to the group and then programmatically select that button to turn off all the displayed radio buttons. For example, a normal button with the label "none" could be wired to select the invisible radio button.
| Property | Defined by | ||
|---|---|---|---|
| buttons : Array | ButtonGroup | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new
ButtonGroup. | ButtonGroup | ||
|
append(b:AbstractButton):void
Adds the button to the group.
| ButtonGroup | ||
|
appendAll(... buttons):void
Appends all buttons into this group.
| ButtonGroup | ||
|
contains(b:AbstractButton):Boolean
Returns whether the group contains the button.
| ButtonGroup | ||
|
getButtonCount():Number
Returns the number of buttons in the group.
| ButtonGroup | ||
|
getElements():Array
Returns all the buttons that are participating in this group.
| ButtonGroup | ||
|
Return the first selected button, if none, return null.
| ButtonGroup | ||
|
Returns the model of the selected button.
| ButtonGroup | ||
|
groupButtons(... buttons):ButtonGroup
[static]
Create a button group and append the buttons in, then return the group.
| ButtonGroup | ||
|
isSelected(m:ButtonModel):Boolean
Returns whether a
ButtonModel is selected. | ButtonGroup | ||
|
remove(b:AbstractButton):void
Removes the button from the group.
| ButtonGroup | ||
|
setSelected(m:ButtonModel, b:Boolean):void
Sets the selected value for the
ButtonModel. | ButtonGroup | ||
| buttons | property |
protected var buttons:Array
| ButtonGroup | () | constructor |
public function ButtonGroup()
Creates a new ButtonGroup.
| append | () | method |
public function append(b:AbstractButton):voidAdds the button to the group.
Parametersb:AbstractButton — the button to be added
|
| appendAll | () | method |
public function appendAll(... buttons):voidAppends all buttons into this group.
Parameters... buttons |
| contains | () | method |
public function contains(b:AbstractButton):BooleanReturns whether the group contains the button.
Parametersb:AbstractButton |
Boolean — true if the group contains the button, false otherwise
|
| getButtonCount | () | method |
public function getButtonCount():NumberReturns the number of buttons in the group.
ReturnsNumber — the button count
|
| getElements | () | method |
public function getElements():ArrayReturns all the buttons that are participating in this group.
ReturnsArray — an Array of the buttons in this group
|
| getSelectedButton | () | method |
public function getSelectedButton():AbstractButtonReturn the first selected button, if none, return null.
ReturnsAbstractButton |
| getSelection | () | method |
public function getSelection():ButtonModelReturns the model of the selected button.
ReturnsButtonModel —
the selected button model
|
| groupButtons | () | method |
public static function groupButtons(... buttons):ButtonGroupCreate a button group and append the buttons in, then return the group.
Parameters... buttons |
ButtonGroup —
the button group.
|
| isSelected | () | method |
public function isSelected(m:ButtonModel):Boolean
Returns whether a ButtonModel is selected.
m:ButtonModel |
Boolean — true if the button is selected, otherwise returns
false
|
| remove | () | method |
public function remove(b:AbstractButton):voidRemoves the button from the group.
Parametersb:AbstractButton — the button to be removed
|
| setSelected | () | method |
public function setSelected(m:ButtonModel, b:Boolean):void
Sets the selected value for the ButtonModel. Only one
button in the group may be selected at a time.
m:ButtonModel — the ButtonModel
|
|
b:Boolean — true if this button is to be selected,
otherwise false
|