Check boxes

JWt provides different kinds of button widgets. The WCheckBox class provides independent on/off options in contrast to WRadioButtons which are usually mutually exclusive.

An instance of WCheckBox corresponds to an HTML <input type="checkbox"> element.

Next to being checked or unchecked, a checkbox can be configured to allow a third state, JWt.PartiallyChecked, which can be used to indicate that it isn't entirely checked, e.g. if only some of the files in a folder are selected, then the checkbox for that folder would be partially checked. In the example below, the third checkbox demonstrates this tristate behaviour.

Inline check boxes

By default, check boxes will appear on the same line.

Example
source
  void CheckBoxInline() {
    WContainerWidget result = new WContainerWidget();
    WCheckBox cb;
    cb = new WCheckBox("Check me!", (WContainerWidget) result);
    cb.setChecked(true);
    cb = new WCheckBox("Check me too!", (WContainerWidget) result);
    cb = new WCheckBox("Check me, I'm tristate!", (WContainerWidget) result);
    cb.setTristate();
    cb.setCheckState(CheckState.PartiallyChecked);
  }

Stacked check boxes

Since by default, check boxes are inline, you will need to use setInline(false) to let them stack vertically.

Example
source
  void CheckBoxStack() {
    WContainerWidget result = new WContainerWidget();
    WCheckBox cb;
    cb = new WCheckBox("Check me!", (WContainerWidget) result);
    cb.setInline(false);
    cb.setChecked(true);
    cb = new WCheckBox("Check me too!", (WContainerWidget) result);
    cb.setInline(false);
    cb = new WCheckBox("Check me, I'm tristate!", (WContainerWidget) result);
    cb.setInline(false);
    cb.setTristate();
    cb.setCheckState(CheckState.PartiallyChecked);
  }

Top