Class WRadioButton


public class WRadioButton extends WAbstractToggleButton
A user control that represents a radio button.

Use a WButtonGroup to group together radio buttons that reflect options that are mutually exclusive.

Usage example:


 enum Vote { Republican, Democrate, NoVote };

 // use a group box as widget container for 3 radio buttons, with a title
 WGroupBox container = new WGroupBox("USA elections vote");

 // use a button group to logically group the 3 options
 WButtonGroup group = new WButtonGroup(this);

 WRadioButton button;
 button = new WRadioButton("I voted Republican", container);
 new WBreak(container);
 group.addButton(button, Vote.Republican.ordinal());
 button = new WRadioButton("I voted Democrat", container);
 new WBreak(container);
 group.addButton(button, Vote.Democrate.ordinal());

 button = new WRadioButton("I didn't vote", container);
 new WBreak(container);
 group.addButton(button, Vote.NoVote.ordinal());

 group.setCheckedButton(group.button(Vote.NoVote.ordinal()));

 

WRadioButton is an inline widget.

CSS

This widget corresponds to the HTML <input type="radio"> tag. When a label is specified, the input element is nested in a <label>.

This widget does not provide styling, and can be styled using inline or external CSS as appropriate.

See Also: