Class WCheckBox
- java.lang.Object
-
public class WCheckBox extends WAbstractToggleButton
A user control that represents a check box.By default, a checkbox can have two states:
CheckState.CheckedorCheckState.Unchecked, which can be inspected usingWAbstractToggleButton.isChecked(), and set usingWAbstractToggleButton.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 usingsetTristate(), and usesetCheckState()andgetCheckState()to read all three states. Once a tri-state checkbox is clicked, it cycles through the statesCheckState.CheckedandCheckState.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
inlinewidget.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
-
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WCheckBox()Creates a checkbox without label.WCheckBox(WContainerWidget parentContainer)Creates a checkbox without label.WCheckBox(java.lang.CharSequence text)Creates a checkbox with given label.WCheckBox(java.lang.CharSequence text, WContainerWidget parentContainer)Creates a checkbox with given label.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CheckStategetCheckState()Returns the check state.booleanisPartialStateSelectable()return partial state cyclingbooleanisTristate()Returns whether the checkbox is tristate.voidsetCheckState(CheckState state)Sets the check state.voidsetPartialStateSelectable(boolean t)enable or disable cycling throught partial statevoidsetTristate()Makes a tristate checkbox.voidsetTristate(boolean tristate)Makes a tristate checkbox.protected voidupdateJSlot()protected voidupdateNextState()-
Methods inherited from class eu.webtoolkit.jwt.WAbstractToggleButton
checked, getText, getTextFormat, getValueText, isChecked, isWordWrap, refresh, remove, setChecked, setChecked, setFormData, setText, setTextFormat, setUnChecked, setValueText, setWordWrap, unChecked
-
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getLabel, getPlaceholderText, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, propagateSetEnabled, render, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validated, validatorChanged
-
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
-
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getDomChanges, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, 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
getObjectName
-
-
-
-
Constructor Detail
-
WCheckBox
public WCheckBox(WContainerWidget parentContainer)
Creates a checkbox without label.A checkbox created by this constructor will not contain a placeholder for a label, and therefore it is not possible to assign a label to it later through
WAbstractToggleButton#setText().
-
WCheckBox
public WCheckBox()
Creates a checkbox without label.
-
WCheckBox
public WCheckBox(java.lang.CharSequence text, WContainerWidget parentContainer)Creates a checkbox with given label.
-
WCheckBox
public WCheckBox(java.lang.CharSequence text)
Creates a checkbox with given label.
-
-
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)
-
setPartialStateSelectable
public void setPartialStateSelectable(boolean t)
enable or disable cycling throught partial state- See Also:
isPartialStateSelectable()
-
isPartialStateSelectable
public boolean isPartialStateSelectable()
return partial state cycling- See Also:
setPartialStateSelectable(boolean t)
-
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.CheckedandCheckState.Uncheckedare valid states.
-
getCheckState
public CheckState getCheckState()
Returns the check state.
-
updateJSlot
protected void updateJSlot()
-
updateNextState
protected void updateNextState()
-
-