Class ButtonGroup
java.lang.Object
vaadinx.swing.ButtonGroup
- All Implemented Interfaces:
Serializable
Emulator port of
ButtonGroup, accepting
AbstractButton subclasses (the JDK class accepts
javax.swing.AbstractButton, which our ported subclasses do not
extend). Coordinates the buttons' ButtonModels as the
JDK's does: getSelection() is the selected button's model, and
setSelected(javax.swing.ButtonModel, boolean) deselects the previous
selection before selecting the new one.
The JDK keeps a model's group on the model, as a javax.swing.ButtonGroup,
which this group is not. So membership is recorded on the emulator's
JToggleButton.ToggleButtonModel instead, whose setSelected
consults the group where the JDK's consults its own — which is what makes a
browser click on a selected radio button leave it selected. A button whose model
is some other ButtonModel joins the group's bookkeeping but is never
consulted, as a JButton's DefaultButtonModel is not in the JDK.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a button;nullis a silent no-op, as in the JDK.voidClears the selection: afterwards no button in the group is selected.intbooleanvoidRemoves a button;nullis a silent no-op, as in the JDK.voidsetSelected(ButtonModel m, boolean b) Makesmthe selection whenbistrue, deselecting the previous one first.
-
Field Details
-
buttons
-
-
Constructor Details
-
ButtonGroup
public ButtonGroup()Default constructor — empty group, no selection.
-
-
Method Details
-
add
Adds a button;nullis a silent no-op, as in the JDK. A selected newcomer becomes the selection unless there already is one, in which case it is deselected before it joins, so the group does not veto that. -
remove
Removes a button;nullis a silent no-op, as in the JDK. -
clearSelection
public void clearSelection()Clears the selection: afterwards no button in the group is selected. -
getElements
-
getSelection
-
setSelected
Makesmthe selection whenbistrue, deselecting the previous one first. Deselecting is not done here:falsedoes nothing. -
isSelected
-
getButtonCount
public int getButtonCount()
-