public class ButtonGroup
extends java.lang.Object
Clickable's
models and
provides unique selection in them. There is capability to add a default
selection. Models who want to belong to the group should just add themselves
to this group. By doing so they listen to this group for changes.
Setting of the default selection results in its being selected any time
setSelected(ButtonModel, boolean)
is called. If no default selection
is set, the last entry selected is not allowed to deselect.
Constructor and Description |
---|
ButtonGroup()
Constructs a ButtonGroup with no default selection.
|
Modifier and Type | Method and Description |
---|---|
void |
add(ButtonModel model)
Adds the passed ButtonModel to the ButtonGroup.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the passed listener.
|
protected void |
firePropertyChange(java.lang.Object oldValue,
java.lang.Object newValue)
Fires a PropertyChangeEvent to all PropertyChangeListeners added to this
ButtonGroup.
|
ButtonModel |
getDefault()
Returns the ButtonModel which is selected by default for this
ButtonGroup.
|
java.util.List |
getElements()
Returns a List which contains all of the
ButtonModels
added to this ButtonGroup. |
ButtonModel |
getSelected()
Returns the ButtonModel for the currently selected button.
|
boolean |
isSelected(ButtonModel model)
Determines if the given ButtonModel is selected or not.
|
void |
remove(ButtonModel model)
Removes the given ButtonModel from this ButtonGroup.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the passed PropertyChangeListener from this ButtonGroup.
|
protected void |
selectNewModel(ButtonModel model)
Sets the passed ButtonModel to be the currently selected ButtonModel of
this ButtonGroup.
|
void |
setDefault(ButtonModel model)
Sets the default selection of this ButtonGroup.
|
void |
setSelected(ButtonModel model)
Sets the button with the given ButtonModel to be selected.
|
void |
setSelected(ButtonModel model,
boolean value)
Sets model to the passed state.
|
public ButtonGroup()
public void add(ButtonModel model)
model
- ButtonModel to be added to this grouppublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- Listener to be added to this groupprotected void firePropertyChange(java.lang.Object oldValue, java.lang.Object newValue)
oldValue
- Old selection valuenewValue
- New selection valuepublic ButtonModel getDefault()
public java.util.List getElements()
ButtonModels
added to this ButtonGroup.public ButtonModel getSelected()
public boolean isSelected(ButtonModel model)
model
- Model being tested for selected statuspublic void remove(ButtonModel model)
model
- ButtonModel being removedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- PropertyChangeListener to be removedprotected void selectNewModel(ButtonModel model)
model
- ButtonModel to be selectedpublic void setDefault(ButtonModel model)
model
- ButtonModel which is to be the default selection.public void setSelected(ButtonModel model)
model
- The ButtonModel to be selectedpublic void setSelected(ButtonModel model, boolean value)
If value is
true
:
false
:
model
- The model to be affectedvalue
- The selected stateCopyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.