Class CommandToggleButtonGroup
java.lang.Object
org.pushingpixels.flamingo.api.common.CommandToggleButtonGroup
- All Implemented Interfaces:
Serializable
Group of command toggle buttons. Unlike the
ButtonGroup
, this class
operates on buttons and not on button models.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Iffalse
, the selection cannot be cleared.protected Vector<JCommandToggleButton>
Contains all group buttons.protected Map<JCommandToggleButton,
ChangeListener> Map of registered model change listeners.static final String
Name of the property change event fired when the group selection is changed.protected JCommandToggleButton
The currently selected button. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified button to the group.void
Adds the specified property change listener on this button group.void
Clears the selection of this button group.protected void
firePropertyChange
(String propertyName, Object oldValue, Object newValue) Fires a property change event on all registered listeners.Returns the selected button of this group.boolean
Returns the current value for clearing selection.void
Removes the specified button from the group.void
Removes the specified property change listener from this button group.void
setAllowsClearingSelection
(boolean allowsClearingSelection) Sets the new value for clearing selection.void
setSelected
(JCommandToggleButton button, boolean isSelected) Changes the selected status of the specified button.
-
Field Details
-
buttons
Contains all group buttons. -
modelChangeListeners
Map of registered model change listeners. -
SELECTED_PROPERTY
Name of the property change event fired when the group selection is changed.- See Also:
-
selection
The currently selected button. Can benull
. -
allowsClearingSelection
protected boolean allowsClearingSelectionIffalse
, the selection cannot be cleared. By default the button group allows clearing the selection inclearSelection()
orsetSelected(JCommandToggleButton, boolean)
(passing the currently selected button andfalse
).
-
-
Constructor Details
-
CommandToggleButtonGroup
public CommandToggleButtonGroup()Creates a new button group.
-
-
Method Details
-
setAllowsClearingSelection
public void setAllowsClearingSelection(boolean allowsClearingSelection) Sets the new value for clearing selection. Iftrue
is passed, the selection can be cleared inclearSelection()
orsetSelected(JCommandToggleButton, boolean)
(passing the currently selected button andfalse
).- Parameters:
allowsClearingSelection
- The new value for clearing selection.
-
isAllowsClearingSelection
public boolean isAllowsClearingSelection()Returns the current value for clearing selection.true
is returned when selection can be cleared inclearSelection()
orsetSelected(JCommandToggleButton, boolean)
(passing the currently selected button andfalse
).- Returns:
- The current value for clearing selection.
-
add
Adds the specified button to the group. If the button is selected, and the group has a selected button, the newly added button is marked as unselected.- Parameters:
b
- The button to be added.
-
remove
Removes the specified button from the group.- Parameters:
b
- The button to be removed
-
setSelected
Changes the selected status of the specified button.- Parameters:
button
- Button.isSelected
- Selection indication.
-
getSelected
Returns the selected button of this group.- Returns:
- The selected button of this group. The result can be
null
.
-
clearSelection
public void clearSelection()Clears the selection of this button group. -
addPropertyChangeListener
Adds the specified property change listener on this button group.- Parameters:
listener
- Listener to add.
-
removePropertyChangeListener
Removes the specified property change listener from this button group.- Parameters:
listener
- Listener to remove.
-
firePropertyChange
Fires a property change event on all registered listeners.- Parameters:
propertyName
- Name of the changed property.oldValue
- Old property value.newValue
- New property value.
-