|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object be.ugent.caagt.swirl.GenericSelectionGroup<E>
public class GenericSelectionGroup<E>
Acts like a button group with associated generic selection model for
type E
. Similar
to SelectionGroup
but backed by a GenericSelectionModel
instead of a SingleSelectionModel
.
Of all toggle buttons
added to a group of this kind, at most one can be selected at the same time.
Every time a new selection is made, this is reported to the selection model.
Each button added to the group is given an associated object
of type E
.
When a new object is selected in the model, the corresponding button will
be selected and the old button will be deselected.
Provides convenience methods to add listeners to the associated selection model and to determine what is the currently selected button.
Note:
In typical applications of this class E
will denote an enumeration type.
It is always required that E
has implementations of
hashCode
and equals
that are compatible.
SelectionGroup
Constructor Summary | |
---|---|
GenericSelectionGroup()
Create a selection group with a newly created selection model and no buttons. |
|
GenericSelectionGroup(boolean clearable)
Create a selection group with a newly created selection model and no buttons. |
|
GenericSelectionGroup(GenericSelectionModel<E> model,
boolean clearable)
Create a selection group with the given model. |
Method Summary | |
---|---|
void |
add(javax.swing.AbstractButton button,
E element)
Add the given button to the group. |
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Register the listener with the model. |
java.lang.String |
getActionCommand()
Return the action command of the currently selected button, or null if none is selected. |
GenericSelectionModel<E> |
getModel()
The selection model used by this group. |
javax.swing.AbstractButton |
getSelectedButton()
Return the button which is currently selected. |
E |
getSelection()
Return the current selection. |
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Unregister the listener from the model. |
void |
setSelection(E element)
Set the current selection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericSelectionGroup()
GenericSelectiongroup(true)
.
public GenericSelectionGroup(boolean clearable)
clearable
- indicates whether buttons can be cleared by clicking
on them. If false the group behaves like a button group.public GenericSelectionGroup(GenericSelectionModel<E> model, boolean clearable)
clearable
- indicates whether buttons can be cleared by clicking
on them. If false the group behaves like a button group.Method Detail |
---|
public GenericSelectionModel<E> getModel()
public void addChangeListener(javax.swing.event.ChangeListener listener)
public void removeChangeListener(javax.swing.event.ChangeListener listener)
public void add(javax.swing.AbstractButton button, E element)
button
- Button to be addedelement
- Element which correspond to this buttonpublic javax.swing.AbstractButton getSelectedButton()
public E getSelection()
public java.lang.String getActionCommand()
public void setSelection(E element)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |