|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.ButtonGroup
com.levigo.util.swing.JButtonGroup
public class JButtonGroup
JButtonGroup
is an useful enhanced version of its ancestor class
ButtonGroup
. It provides the possibility to listen to button group and
selection changes, but also it allows to clear the button group selection.
Field Summary |
---|
Fields inherited from class javax.swing.ButtonGroup |
---|
buttons |
Constructor Summary | |
---|---|
JButtonGroup()
Creates an empty JButtonGroup |
|
JButtonGroup(javax.swing.AbstractButton[] buttons)
Creates a JButtonGroup object from an array of buttons and adds the buttons to the
group. |
Method Summary | |
---|---|
void |
add(javax.swing.AbstractButton button)
Adds a button to the group |
void |
add(javax.swing.AbstractButton[] buttons)
Adds an array of buttons to the group |
void |
addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the button. |
void |
clearSelection()
Clears the current selection. |
boolean |
contains(javax.swing.AbstractButton button)
Checks whether the group contains the given button |
protected void |
fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. |
javax.swing.AbstractButton |
getButton(javax.swing.ButtonModel model)
Returns the AbstractButton whose ButtonModel is given. |
int |
getButtonCount()
|
java.util.List<javax.swing.AbstractButton> |
getButtons()
Returns the buttons in the group as a List |
javax.swing.AbstractButton |
getSelected()
Returns the selected button in the group. |
javax.swing.ButtonModel |
getSelection()
|
boolean |
isSelected(javax.swing.AbstractButton button)
Returns whether the button is selected |
void |
remove(javax.swing.AbstractButton button)
Removes a button from the group |
void |
remove(javax.swing.AbstractButton[] buttons)
Removes all the buttons in the array from the group |
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the button. |
void |
setSelected(javax.swing.AbstractButton button,
boolean selected)
Sets the selected button in the group Only one button in the group can be selected |
void |
setSelected(javax.swing.ButtonModel model,
boolean selected)
Sets the selected button model in the group |
Methods inherited from class javax.swing.ButtonGroup |
---|
getElements, isSelected |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JButtonGroup()
JButtonGroup
public JButtonGroup(javax.swing.AbstractButton[] buttons)
JButtonGroup
object from an array of buttons and adds the buttons to the
group. No button will be selected initially.
buttons
- an array of AbstractButton
sMethod Detail |
---|
public void addChangeListener(javax.swing.event.ChangeListener l)
ChangeListener
to the button.
l
- the listener to addpublic void removeChangeListener(javax.swing.event.ChangeListener l)
ChangeListener
from the button.
l
- the listener to removeprotected void fireStateChanged()
EventListenerList
public void add(javax.swing.AbstractButton button)
add
in class javax.swing.ButtonGroup
button
- an AbstractButton
referencepublic void add(javax.swing.AbstractButton[] buttons)
buttons
- an array of AbstractButton
spublic void remove(javax.swing.AbstractButton button)
remove
in class javax.swing.ButtonGroup
button
- the button to be removedpublic void remove(javax.swing.AbstractButton[] buttons)
buttons
- an array of AbstractButton
spublic void setSelected(javax.swing.AbstractButton button, boolean selected)
button
- an AbstractButton
referenceselected
- an boolean
representing the selection state of the buttonpublic void setSelected(javax.swing.ButtonModel model, boolean selected)
setSelected
in class javax.swing.ButtonGroup
model
- a ButtonModel
referenceselected
- an boolean
representing the selection state of the buttonpublic javax.swing.AbstractButton getButton(javax.swing.ButtonModel model)
AbstractButton
whose ButtonModel
is given. If the model
does not belong to a button in the group, returns null.
model
- a ButtonModel
that should belong to a button in the group
AbstractButton
reference whose model is model
if the
button belongs to the group, null
otherwisepublic javax.swing.AbstractButton getSelected()
null
if no
button is selectedpublic javax.swing.ButtonModel getSelection()
getSelection
in class javax.swing.ButtonGroup
public boolean isSelected(javax.swing.AbstractButton button)
button
- an AbstractButton
reference
true
if the button is selected, false
otherwisepublic java.util.List<javax.swing.AbstractButton> getButtons()
List
List
containing the buttons in the group, in the order they were added
to the grouppublic boolean contains(javax.swing.AbstractButton button)
button
-
true
if the button is contained in the group, false
otherwisepublic void clearSelection()
clearSelection
in class javax.swing.ButtonGroup
public int getButtonCount()
getButtonCount
in class javax.swing.ButtonGroup
ButtonGroup.getButtonCount()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |