|
||||||||||
| 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 AbstractButtons| Method 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()
EventListenerListpublic void add(javax.swing.AbstractButton button)
add in class javax.swing.ButtonGroupbutton - an AbstractButton referencepublic void add(javax.swing.AbstractButton[] buttons)
buttons - an array of AbstractButtonspublic void remove(javax.swing.AbstractButton button)
remove in class javax.swing.ButtonGroupbutton - the button to be removedpublic void remove(javax.swing.AbstractButton[] buttons)
buttons - an array of AbstractButtons
public void setSelected(javax.swing.AbstractButton button,
boolean selected)
button - an AbstractButton referenceselected - an boolean representing the selection state of the button
public void setSelected(javax.swing.ButtonModel model,
boolean selected)
setSelected in class javax.swing.ButtonGroupmodel - 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, nullotherwisepublic javax.swing.AbstractButton getSelected()
null if no
button is selectedpublic javax.swing.ButtonModel getSelection()
getSelection in class javax.swing.ButtonGrouppublic 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.ButtonGrouppublic int getButtonCount()
getButtonCount in class javax.swing.ButtonGroupButtonGroup.getButtonCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||