Class WCheckBox


public class WCheckBox
extends WAbstractToggleButton
A user control that represents a check box.

By default, a checkbox can have two states: CheckState.Checked or CheckState.Unchecked, which can be inspected using WAbstractToggleButton.isChecked(), and set using WAbstractToggleButton.setChecked().

A checkbox may also provide a third state, CheckState.PartiallyChecked, which is useful to indicate that it is neither checked nor unchecked. JWt will use native browser support for this HTML5 extension when available (Safari and MS IE), and use an image-based workaround otherwise. You may enable support for the third state using setTristate(), and use setCheckState() and getCheckState() to read all three states. Once a tri-state checkbox is clicked, it cycles through the states CheckState.Checked and CheckState.Unchecked.

A label is added as a sibling of the checkbox to the same parent.

Usage example:


 WGroupBox box = new WGroupBox("In-flight options");

 WCheckBox w1 = new WCheckBox("Vegetarian diet", box);
 box.addWidget(new WBreak());
 WCheckBox w2 = new WCheckBox("WIFI access", box);
 box.addWidget(new WBreak());
 WCheckBox w3 = new WCheckBox("AC plug", box);

 w1.setChecked(false);
 w2.setChecked(true);
 w3.setChecked(true);

 

WCheckBox is an inline widget.

CSS

This widget is rendered using an HTML <input type="checkbox"> 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:
WAbstractToggleButton