eu.webtoolkit.jwt
Class WCheckBox

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by eu.webtoolkit.jwt.WFormWidget
                      extended by eu.webtoolkit.jwt.WAbstractToggleButton
                          extended by eu.webtoolkit.jwt.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 or 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.

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

Usage example:

 {
        @code
        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 corresponds to the HTML <input type="checkbox"> tag. Depending on whether a text is included, it may be nested in a <span> tag which also includes a rendered WLabel. This widget does not provide styling, and can be styled using inline or external CSS as appropriate.

See Also:
WAbstractToggleButton

Constructor Summary
WCheckBox()
          Creates a checkbox with empty label.
WCheckBox(java.lang.CharSequence text)
          Creates a checkbox with given label.
WCheckBox(java.lang.CharSequence text, WContainerWidget parent)
          Creates a checkbox with given label.
WCheckBox(WContainerWidget parent)
          Creates a checkbox with empty label.
 
Method Summary
 CheckState getCheckState()
          Returns the check state.
 boolean isTristate()
          Returns whether the checkbox is tristate.
 void setCheckState(CheckState state)
          Sets the check state.
 void setTristate()
          Makes a tristate checkbox.
 void setTristate(boolean tristate)
          Makes a tristate checkbox.
 
Methods inherited from class eu.webtoolkit.jwt.WAbstractToggleButton
checked, getText, getValueText, isChecked, remove, setChecked, setChecked, setText, setUnChecked, setValueText, unChecked
 
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
blurred, changed, enableAjax, focussed, getEmptyText, getLabel, getTabIndex, getValidator, hasFocus, isReadOnly, propagateSetEnabled, refresh, render, selected, setEmptyText, setEnabled, setFocus, setFocus, setHidden, setReadOnly, setTabIndex, setValidator, validate, validated
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, doJavaScript, domCanBeSaved, escapeText, escapeText, escapeText, escapeText, find, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, removeScript, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setToolTip, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WCheckBox

public WCheckBox(WContainerWidget parent)
Creates a checkbox with empty label.


WCheckBox

public WCheckBox()
Creates a checkbox with empty label.

Calls this((WContainerWidget)null)


WCheckBox

public WCheckBox(java.lang.CharSequence text,
                 WContainerWidget parent)
Creates a checkbox with given label.


WCheckBox

public WCheckBox(java.lang.CharSequence text)
Creates a checkbox with given label.

Calls this(text, (WContainerWidget)null)

Method Detail

setTristate

public void setTristate(boolean tristate)
Makes a tristate checkbox.

Note: You should enable tristate functionality right after construction and this cannot be modified later.


setTristate

public final void setTristate()
Makes a tristate checkbox.

Calls setTristate(true)


isTristate

public boolean isTristate()
Returns whether the checkbox is tristate.

See Also:
setTristate(boolean tristate)

setCheckState

public void setCheckState(CheckState state)
Sets the check state.

Unless it is a tri-state checkbox, only CheckState.Checked and CheckState.Unchecked are valid states.


getCheckState

public CheckState getCheckState()
Returns the check state.

See Also:
setCheckState(CheckState state), WAbstractToggleButton.isChecked()