Class CommandToggleButtonGroup
- java.lang.Object
-
- org.pushingpixels.flamingo.api.common.CommandToggleButtonGroup
-
- All Implemented Interfaces:
Serializable
public class CommandToggleButtonGroup extends Object implements Serializable
Group of command toggle buttons. Unlike theButtonGroup
, this class operates on buttons and not on button models.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowsClearingSelection
Iffalse
, the selection cannot be cleared.protected Vector<JCommandToggleButton>
buttons
Contains all group buttons.protected Map<JCommandToggleButton,ChangeListener>
modelChangeListeners
Map of registered model change listeners.static String
SELECTED_PROPERTY
Name of the property change event fired when the group selection is changed.protected JCommandToggleButton
selection
The currently selected button.
-
Constructor Summary
Constructors Constructor Description CommandToggleButtonGroup()
Creates a new button group.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(JCommandToggleButton b)
Adds the specified button to the group.void
addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified property change listener on this button group.void
clearSelection()
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.JCommandToggleButton
getSelected()
Returns the selected button of this group.boolean
isAllowsClearingSelection()
Returns the current value for clearing selection.void
remove(JCommandToggleButton b)
Removes the specified button from the group.void
removePropertyChangeListener(PropertyChangeListener listener)
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 Detail
-
buttons
protected Vector<JCommandToggleButton> buttons
Contains all group buttons.
-
modelChangeListeners
protected Map<JCommandToggleButton,ChangeListener> modelChangeListeners
Map of registered model change listeners.
-
SELECTED_PROPERTY
public static final String SELECTED_PROPERTY
Name of the property change event fired when the group selection is changed.- See Also:
- Constant Field Values
-
selection
protected JCommandToggleButton selection
The currently selected button. Can benull
.
-
allowsClearingSelection
protected boolean allowsClearingSelection
Iffalse
, the selection cannot be cleared. By default the button group allows clearing the selection inclearSelection()
orsetSelected(JCommandToggleButton, boolean)
(passing the currently selected button andfalse
).
-
-
Method Detail
-
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
public void add(JCommandToggleButton b)
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
public void remove(JCommandToggleButton b)
Removes the specified button from the group.- Parameters:
b
- The button to be removed
-
setSelected
public void setSelected(JCommandToggleButton button, boolean isSelected)
Changes the selected status of the specified button.- Parameters:
button
- Button.isSelected
- Selection indication.
-
getSelected
public JCommandToggleButton 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
public void addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified property change listener on this button group.- Parameters:
listener
- Listener to add.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified property change listener from this button group.- Parameters:
listener
- Listener to remove.
-
-