Package org.pushingpixels.flamingo.api.common

# 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 the `ButtonGroup`, 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`
If `false`, 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 final 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

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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### 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 be `null`.

### allowsClearingSelection

protected boolean allowsClearingSelection
If `false`, the selection cannot be cleared. By default the button group allows clearing the selection in `clearSelection()` or `setSelected(JCommandToggleButton, boolean)` (passing the currently selected button and `false`).

## 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. If `true` is passed, the selection can be cleared in `clearSelection()` or `setSelected(JCommandToggleButton, boolean)` (passing the currently selected button and `false`).

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 in `clearSelection()` or `setSelected(JCommandToggleButton, boolean)` (passing the currently selected button and `false`).

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.

### firePropertyChange

protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
Fires a property change event on all registered listeners.

Parameters:
  `propertyName` - Name of the changed property.
  `oldValue` - Old property value.
  `newValue` - New property value.