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 new(): Void

Creates a new ButtonGroup.

function append(b:AbstractButton): Void

Adds the button to the group.

b

the button to be added

function appendAll(buttons:Array<Dynamic>): Void

Appends all buttons into this group.

function contains(b:AbstractButton): Bool

Returns whether the group contains the button.

returns

true if the group contains the button, false otherwise

function getButtonCount(): Float

Returns the number of buttons in the group.

returns

the button count

function getElements(): Array<Dynamic>

Returns all the buttons that are participating in this group.

returns

an Array of the buttons in this group

function getSelectedButton(): AbstractButton

Return the first selected button, if none, return null.

function getSelectedIndex(): Int

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.

returnstrue if the button is selected, otherwise returns false

function remove(b:AbstractButton): Void

Removes the button from the group.

b

the button to be removed

function setAllowUncheck(allowUncheck:Bool): Void

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 ButtonModel

btrue if this button is to be selected, otherwise false