Package rma.swing
Class JButtonGroup
java.lang.Object
javax.swing.ButtonGroup
rma.swing.JButtonGroup
- All Implemented Interfaces:
Serializable
Extends
javax.swing.ButtonGroup
to provide methods that allow working with button references instead of button models.- See Also:
-
Field Summary
Fields inherited from class javax.swing.ButtonGroup
buttons
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an emptyJButtonGroup
JButtonGroup
(AbstractButton[] buttons) Creates aJButtonGroup
object from an array of buttons and adds the buttons to the group No button will be selected initially. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(AbstractButton button) Adds a button to the groupvoid
add
(AbstractButton[] buttons) Adds an array of buttons to the groupboolean
contains
(AbstractButton button) Checks whether the group contains the given buttongetButton
(ButtonModel model) Returns theAbstractButton
whoseButtonModel
is given.Returns the buttons in the group as aList
Returns the selected button in the group.boolean
isSelected
(AbstractButton button) Returns whether the button is selectedvoid
remove
(AbstractButton button) Removes a button from the groupvoid
remove
(AbstractButton[] buttons) Removes all the buttons in the array from the groupvoid
setSelected
(AbstractButton button, boolean selected) Sets the selected button in the group Only one button in the group can be selectedvoid
setSelected
(ButtonModel model, boolean selected) Sets the selected button model in the groupMethods inherited from class javax.swing.ButtonGroup
clearSelection, getButtonCount, getElements, getSelection, isSelected
-
Constructor Details
-
JButtonGroup
public JButtonGroup()Creates an emptyJButtonGroup
-
JButtonGroup
Creates aJButtonGroup
object from an array of buttons and adds the buttons to the group No button will be selected initially.- Parameters:
buttons
- an array ofAbstractButton
s
-
-
Method Details
-
add
Adds a button to the group- Overrides:
add
in classButtonGroup
- Parameters:
button
- anAbstractButton
reference
-
add
Adds an array of buttons to the group- Parameters:
buttons
- an array ofAbstractButton
s
-
remove
Removes a button from the group- Overrides:
remove
in classButtonGroup
- Parameters:
button
- the button to be removed
-
remove
Removes all the buttons in the array from the group- Parameters:
buttons
- an array ofAbstractButton
s
-
setSelected
Sets the selected button in the group Only one button in the group can be selected- Parameters:
button
- anAbstractButton
referenceselected
- anboolean
representing the selection state of the button
-
setSelected
Sets the selected button model in the group- Overrides:
setSelected
in classButtonGroup
- Parameters:
model
- aButtonModel
referenceselected
- anboolean
representing the selection state of the button
-
getButton
Returns theAbstractButton
whoseButtonModel
is given. If the model does not belong to a button in the group, returns null.- Parameters:
model
- aButtonModel
that should belong to a button in the group- Returns:
- an
AbstractButton
reference whose model ismodel
if the button belongs to the group,null
otherwise
-
getSelected
Returns the selected button in the group.- Returns:
- a reference to the currently selected button in the group or
null
if no button is selected
-
isSelected
Returns whether the button is selected- Parameters:
button
- anAbstractButton
reference- Returns:
true
if the button is selected,false
otherwise
-
getButtons
Returns the buttons in the group as aList
- Returns:
- a
List
containing the buttons in the group, in the order they were added to the group
-
contains
Checks whether the group contains the given button- Returns:
true
if the button is contained in the group,false
otherwise
-