class org.aswing.ButtonGroup
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.
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.
@author paling @author Aron (added the allowUncheck feature)Class Fields
static function groupButtons(buttons:Array<Dynamic>): ButtonGroup
Create a button group and append the buttons in, then return the group.
returns | the button group. |
Instance Fields
function contains(b:AbstractButton): Bool
Returns whether the group contains the button.
returns | true if the group contains the button, false otherwise |
function getElements(): Array<Dynamic>
Returns all the buttons that are participating in this group.
returns | an |
function getSelection(): ButtonModel
Returns the model of the selected button.
returns | the selected button model |
function isSelected(m:ButtonModel): Bool
Returns whether a ButtonModel
is selected.
returns | true if the button is selected, otherwise returns
false |
function setSelected(m:ButtonModel, b:Bool): Void
Sets the selected value for the ButtonModel
. Only one
button in the group may be selected at a time.
m | the |
b | true if this button is to be selected,
otherwise false |