Class WButtonGroup
public class WButtonGroup extends WObject
A button group manages a set of radio buttons
, making them exclusive of
each other.
It is not a widget, but instead provides only a logical grouping. Radio buttons are aware of
the group in which they have been added, see WRadioButton.getGroup()
. When a button is
deleted, it is automatically removed its button group.
It allows you to associate id's with each button, which you may use to identify a particular button. The special value of -1 is reserved to indicate no button.
- See Also:
WRadioButton
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
Constructors Constructor Description WButtonGroup()
Creates a new empty button group.WButtonGroup(WObject parent)
Creates a new empty button group. -
Method Summary
Modifier and Type Method Description void
addButton(WRadioButton button)
Adds a radio button to the group.void
addButton(WRadioButton button, int id)
Adds a radio button to the group.Signal1<WRadioButton>
checkedChanged()
Signal emitted when a button was checked.WRadioButton
getButton(int id)
Returns the button for the given id.java.util.List<WRadioButton>
getButtons()
Returns the buttons in this group.WRadioButton
getCheckedButton()
Returns the checked radiobutton.int
getCheckedId()
Returns the id of the checked button.int
getCount()
Returns the number of radiobuttons in this group.java.lang.String
getId()
Returns the (unique) identifier for this objectint
getId(WRadioButton button)
Returns the id for the given button.int
getSelectedButtonIndex()
Returns the index of the checked radiobutton.void
removeButton(WRadioButton button)
Removes a radio button from the group.void
setCheckedButton(WRadioButton button)
Sets the currently checked radiobutton.protected void
setFormData(WObject.FormData formData)
void
setSelectedButtonIndex(int idx)
Sets the currently checked radiobutton.Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, remove, setObjectName, tr
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
WButtonGroup
Creates a new empty button group. -
WButtonGroup
public WButtonGroup()Creates a new empty button group.Calls
this((WObject)null)
-
-
Method Details
-
addButton
Adds a radio button to the group.You can assign an id to the button. If
id
is -1, then a unique id will be generated.- See Also:
removeButton(WRadioButton button)
-
addButton
Adds a radio button to the group.Calls
addButton(button, - 1)
-
removeButton
Removes a radio button from the group.- See Also:
addButton(WRadioButton button, int id)
-
getButton
Returns the button for the given id. -
getId
Returns the id for the given button. -
getId
public java.lang.String getId()Description copied from class:WObject
Returns the (unique) identifier for this objectFor a
WWidget
, this corresponds to the id of the DOM element that represents the widget. This is not entirely unique, since aWCompositeWidget
shares the same id as its implementation.By default, the id is auto-generated, unless a custom id is set for a widget using
WWidget.setId(String)
. The auto-generated id is created by concatenatingWObject.getObjectName()
with a unique number. -
getButtons
Returns the buttons in this group. -
getCount
public int getCount()Returns the number of radiobuttons in this group. -
getCheckedId
public int getCheckedId()Returns the id of the checked button.Returns the id of the currently checked button, or -1 if no button is currently checked.
-
setCheckedButton
Sets the currently checked radiobutton.The button
button
of this group is checked. A value ofnull
will uncheck all radiobuttons.Initially, no button is checked.
- See Also:
getCheckedId()
-
getCheckedButton
Returns the checked radiobutton.If there is no radiobutton currently checked this function returns
null
. -
setSelectedButtonIndex
public void setSelectedButtonIndex(int idx)Sets the currently checked radiobutton.Sets the
idx'th
radiobutton checked. A value of -1 will uncheck all radiobuttons.Initially, no button is checked.
-
getSelectedButtonIndex
public int getSelectedButtonIndex()Returns the index of the checked radiobutton.The index reflects the order in which the buttons have been added to the button group. Use
getCheckedId()
if you want to know the id of the button that is currently checked. If there is no radiobutton selected this function returns -1.- See Also:
getCheckedId()
-
checkedChanged
Signal emitted when a button was checked.The argument passed is the new
getCheckedButton()
. -
setFormData
- Overrides:
setFormData
in classWObject
-