|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.ButtonGroup
org.tbee.swing.JButtonGroup
public class JButtonGroup
Extends javax.swing.ButtonGroup to provide methods that allow working with button references instead of button models.
By using
bindValue(button, value)
or the associated
add(button, value)
it is possible to relate a value to a button.
By using setValue(), getValue() and the value property change event, the buttongroup can be bound to a bean property.
ButtonGroup,
Serialized Form| Field Summary | |
|---|---|
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
static java.lang.String |
VALUE_PROPERTY_ID
|
| 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
No button will be selected initially. |
|
| Method Summary | |
|---|---|
void |
add(javax.swing.AbstractButton... buttons)
Adds an array of buttons to the group |
void |
add(javax.swing.AbstractButton button)
Adds a button to the group |
void |
add(javax.swing.AbstractButton button,
java.lang.Object value)
Adds a button to the group |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener o)
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener o)
|
void |
bindValue(javax.swing.AbstractButton button,
java.lang.Object value)
store the relation between button and value |
boolean |
contains(javax.swing.AbstractButton button)
Checks whether the group contains the given button |
void |
firePropertyChange(java.lang.String name,
java.lang.Object before,
java.lang.Object after)
|
void |
fireValueChangedIfRequired()
|
javax.swing.AbstractButton |
getButton(javax.swing.ButtonModel model)
Returns the AbstractButton whose ButtonModel is given. |
java.util.List<javax.swing.AbstractButton> |
getButtons()
Returns the buttons in the group as a List |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
PropertyChange |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners(java.lang.String propertyName)
|
javax.swing.AbstractButton |
getSelected()
Returns the selected button in the group. |
java.lang.Object |
getValue()
|
boolean |
isSelected(javax.swing.AbstractButton button)
Returns whether the button is selected |
void |
remove(javax.swing.AbstractButton... buttons)
Removes all the buttons in the array from the group |
void |
remove(javax.swing.AbstractButton button)
Removes a button from the group |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener o)
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener o)
|
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 |
void |
setValue(java.lang.Object value)
get the value of the selected button |
void |
unbindValue(javax.swing.AbstractButton button)
|
| Methods inherited from class javax.swing.ButtonGroup |
|---|
clearSelection, getButtonCount, getElements, getSelection, isSelected |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SOURCECODE_VERSION
public static final java.lang.String VALUE_PROPERTY_ID
| 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 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 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)
true if the button is contained in the group, false otherwisepublic void setValue(java.lang.Object value)
public java.lang.Object getValue()
public void fireValueChangedIfRequired()
public void bindValue(javax.swing.AbstractButton button,
java.lang.Object value)
public void unbindValue(javax.swing.AbstractButton button)
public void add(javax.swing.AbstractButton button,
java.lang.Object value)
button - an AbstractButton referencepublic java.beans.PropertyChangeListener[] getPropertyChangeListeners()
public void addPropertyChangeListener(java.beans.PropertyChangeListener o)
public void removePropertyChangeListener(java.beans.PropertyChangeListener o)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener o)
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener o)
public void firePropertyChange(java.lang.String name,
java.lang.Object before,
java.lang.Object after)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||