org.gwtbootstrap3.client.ui
Class CheckBox

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.FocusWidget
              extended by com.google.gwt.user.client.ui.ButtonBase
                  extended by org.gwtbootstrap3.client.ui.gwt.ButtonBase
                      extended by org.gwtbootstrap3.client.ui.CheckBox
All Implemented Interfaces:
IsEditor<LeafValueEditor<Boolean>>, HasAllDragAndDropHandlers, HasAllFocusHandlers, HasAllGestureHandlers, HasAllKeyHandlers, HasAllMouseHandlers, HasAllTouchHandlers, HasBlurHandlers, HasChangeHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragEndHandlers, HasDragEnterHandlers, HasDragHandlers, HasDragLeaveHandlers, HasDragOverHandlers, HasDragStartHandlers, HasDropHandlers, HasFocusHandlers, HasGestureChangeHandlers, HasGestureEndHandlers, HasGestureStartHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasTouchCancelHandlers, HasTouchEndHandlers, HasTouchMoveHandlers, HasTouchStartHandlers, HasAttachHandlers, HasValueChangeHandlers<Boolean>, HasHandlers, HasDirectionEstimator, HasSafeHtml, EventListener, TakesValue<Boolean>, Focusable, HasDirectionalSafeHtml, HasDirectionalText, HasEnabled, HasFocus, HasHTML, HasName, HasText, HasValue<Boolean>, HasVisibility, HasWordWrap, IsWidget, SourcesClickEvents, SourcesFocusEvents, SourcesKeyboardEvents, SourcesMouseEvents, HasFormValue, HasId, HasPull, HasResponsiveness
Direct Known Subclasses:
CheckBoxButton, InlineCheckBox, Radio

public class CheckBox
extends ButtonBase
implements HasName, HasValue<Boolean>, HasWordWrap, HasDirectionalSafeHtml, HasDirectionEstimator, IsEditor<LeafValueEditor<Boolean>>, HasFormValue, HasChangeHandlers

A standard check box widget. This class also serves as a base class for Radio.

Built-in Bidi Text Support

This widget is capable of automatically adjusting its direction according to its content. This feature is controlled by setDirectionEstimator(boolean) or passing a DirectionEstimator parameter to the constructor, and is off by default.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
protected  InputElement inputElem
           
protected  SpanElement labelElem
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
  CheckBox()
           
protected CheckBox(Element element, InputElement inputElement)
           
  CheckBox(SafeHtml label)
          Creates a check box with the specified text label.
  CheckBox(SafeHtml label, DirectionEstimator directionEstimator)
          Creates a check box with the specified text label.
  CheckBox(SafeHtml label, HasDirection.Direction dir)
          Creates a check box with the specified text label.
  CheckBox(String label)
          Creates a check box with the specified text label.
  CheckBox(String label, boolean asHTML)
          Creates a check box with the specified text label.
  CheckBox(String label, DirectionEstimator directionEstimator)
          Creates a label with the specified text and a default direction estimator.
  CheckBox(String label, HasDirection.Direction dir)
          Creates a check box with the specified text label.
 
Method Summary
 HandlerRegistration addChangeHandler(ChangeHandler handler)
           
 HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
           
 LeafValueEditor<Boolean> asEditor()
           
protected  void ensureDomEventHandlers()
           
 DirectionEstimator getDirectionEstimator()
           
 String getFormValue()
          Returns the value property of the input element that backs this widget.
 String getHTML()
           
 String getName()
           
 int getTabIndex()
           
 String getText()
           
 HasDirection.Direction getTextDirection()
           
 Boolean getValue()
          Determines whether this check box is currently checked.
 boolean getWordWrap()
           
 boolean isEnabled()
           
protected  void onEnsureDebugId(String baseID)
          Affected Elements: -input = checkbox.
protected  void onLoad()
          This method is called when a widget is attached to the browser's document.
protected  void onUnload()
          This method is called when a widget is detached from the browser's document.
 void setAccessKey(char key)
           
 void setDirectionEstimator(boolean enabled)
          
 void setDirectionEstimator(DirectionEstimator directionEstimator)
          
 void setEnabled(boolean enabled)
           
 void setFocus(boolean focused)
           
 void setFormValue(String value)
          Set the value property on the input element that backs this widget.
 void setHTML(SafeHtml html, HasDirection.Direction dir)
           
 void setHTML(String html)
           
 void setName(String name)
           
 void setTabIndex(int index)
           
 void setText(String text)
           
 void setText(String text, HasDirection.Direction dir)
           
 void setValue(Boolean value)
          Checks or unchecks the check box.
 void setValue(Boolean value, boolean fireEvents)
          Checks or unchecks the check box, firing ValueChangeEvent if appropriate.
 void setWordWrap(boolean wrap)
           
 void sinkEvents(int eventBitsToAdd)
           
 
Methods inherited from class org.gwtbootstrap3.client.ui.gwt.ButtonBase
getId, getPull, setHiddenOn, setId, setPull, setVisibleOn
 
Methods inherited from class com.google.gwt.user.client.ui.ButtonBase
setHTML
 
Methods inherited from class com.google.gwt.user.client.ui.FocusWidget
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, removeFromParent, setLayoutData, unsinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.safehtml.client.HasSafeHtml
setHTML
 

Field Detail

labelElem

protected final SpanElement labelElem

inputElem

protected final InputElement inputElem
Constructor Detail

CheckBox

public CheckBox(SafeHtml label)
Creates a check box with the specified text label.

Parameters:
label - the check box's label

CheckBox

public CheckBox(SafeHtml label,
                HasDirection.Direction dir)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
dir - the text's direction. Note that DEFAULT means direction should be inherited from the widget's parent element.

CheckBox

public CheckBox(SafeHtml label,
                DirectionEstimator directionEstimator)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, #DEFAULT_DIRECTION_ESTIMATOR can be used.

CheckBox

public CheckBox(String label)
Creates a check box with the specified text label.

Parameters:
label - the check box's label

CheckBox

public CheckBox(String label,
                HasDirection.Direction dir)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
dir - the text's direction. Note that DEFAULT means direction should be inherited from the widget's parent element.

CheckBox

public CheckBox(String label,
                DirectionEstimator directionEstimator)
Creates a label with the specified text and a default direction estimator.

Parameters:
label - the check box's label
directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, #DEFAULT_DIRECTION_ESTIMATOR can be used.

CheckBox

public CheckBox(String label,
                boolean asHTML)
Creates a check box with the specified text label.

Parameters:
label - the check box's label
asHTML - true to treat the specified label as html

CheckBox

public CheckBox()

CheckBox

protected CheckBox(Element element,
                   InputElement inputElement)
Method Detail

addValueChangeHandler

public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
Specified by:
addValueChangeHandler in interface HasValueChangeHandlers<Boolean>

addChangeHandler

public HandlerRegistration addChangeHandler(ChangeHandler handler)
Specified by:
addChangeHandler in interface HasChangeHandlers

asEditor

public LeafValueEditor<Boolean> asEditor()
Specified by:
asEditor in interface IsEditor<LeafValueEditor<Boolean>>

getDirectionEstimator

public DirectionEstimator getDirectionEstimator()
Specified by:
getDirectionEstimator in interface HasDirectionEstimator

getFormValue

public String getFormValue()
Returns the value property of the input element that backs this widget. This is the value that will be associated with the CheckBox name and submitted to the server if a FormPanel that holds it is submitted and the box is checked.

Don't confuse this with getValue(), which returns true or false if the widget is checked.

Specified by:
getFormValue in interface HasFormValue

getHTML

public String getHTML()
Specified by:
getHTML in interface HasHTML
Overrides:
getHTML in class ButtonBase

getName

public String getName()
Specified by:
getName in interface HasName

getTabIndex

public int getTabIndex()
Specified by:
getTabIndex in interface Focusable
Overrides:
getTabIndex in class FocusWidget

getText

public String getText()
Specified by:
getText in interface HasText
Overrides:
getText in class ButtonBase

getTextDirection

public HasDirection.Direction getTextDirection()
Specified by:
getTextDirection in interface HasDirectionalText

getValue

public Boolean getValue()
Determines whether this check box is currently checked.

Note that this does not return the value property of the checkbox input element wrapped by this widget. For access to that property, see getFormValue()

Specified by:
getValue in interface TakesValue<Boolean>
Specified by:
getValue in interface HasValue<Boolean>
Returns:
true if the check box is checked, false otherwise. Will not return null

getWordWrap

public boolean getWordWrap()
Specified by:
getWordWrap in interface HasWordWrap

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface HasEnabled
Overrides:
isEnabled in class ButtonBase

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface HasEnabled
Overrides:
setEnabled in class ButtonBase

setAccessKey

public void setAccessKey(char key)
Specified by:
setAccessKey in interface Focusable
Overrides:
setAccessKey in class FocusWidget

setDirectionEstimator

public void setDirectionEstimator(boolean enabled)

See note at setDirectionEstimator(DirectionEstimator).

Specified by:
setDirectionEstimator in interface HasDirectionEstimator

setDirectionEstimator

public void setDirectionEstimator(DirectionEstimator directionEstimator)

Note: DirectionEstimator should be set before the label has any content; it's highly recommended to set it using a constructor. Reason: if the label already has non-empty content, this will update its direction according to the new estimator's result. This may cause flicker, and thus should be avoided.

Specified by:
setDirectionEstimator in interface HasDirectionEstimator

setFocus

public void setFocus(boolean focused)
Specified by:
setFocus in interface Focusable
Overrides:
setFocus in class FocusWidget

setFormValue

public void setFormValue(String value)
Set the value property on the input element that backs this widget. This is the value that will be associated with the CheckBox's name and submitted to the server if a FormPanel that holds it is submitted and the box is checked.

Don't confuse this with setValue(java.lang.Boolean), which actually checks and unchecks the box.

Specified by:
setFormValue in interface HasFormValue
Parameters:
value -

setHTML

public void setHTML(SafeHtml html,
                    HasDirection.Direction dir)
Specified by:
setHTML in interface HasDirectionalSafeHtml

setHTML

public void setHTML(String html)
Specified by:
setHTML in interface HasHTML
Overrides:
setHTML in class ButtonBase

setName

public void setName(String name)
Specified by:
setName in interface HasName

setTabIndex

public void setTabIndex(int index)
Specified by:
setTabIndex in interface Focusable
Overrides:
setTabIndex in class FocusWidget

setText

public void setText(String text)
Specified by:
setText in interface HasText
Overrides:
setText in class ButtonBase

setText

public void setText(String text,
                    HasDirection.Direction dir)
Specified by:
setText in interface HasDirectionalText

setValue

public void setValue(Boolean value)
Checks or unchecks the check box.

Note that this does not set the value property of the checkbox input element wrapped by this widget. For access to that property, see setFormValue(String)

Specified by:
setValue in interface TakesValue<Boolean>
Specified by:
setValue in interface HasValue<Boolean>
Parameters:
value - true to check, false to uncheck; null value implies false

setValue

public void setValue(Boolean value,
                     boolean fireEvents)
Checks or unchecks the check box, firing ValueChangeEvent if appropriate.

Note that this does not set the value property of the checkbox input element wrapped by this widget. For access to that property, see setFormValue(String)

Specified by:
setValue in interface HasValue<Boolean>
Parameters:
value - true to check, false to uncheck; null value implies false
fireEvents - If true, and value has changed, fire a ValueChangeEvent

setWordWrap

public void setWordWrap(boolean wrap)
Specified by:
setWordWrap in interface HasWordWrap

sinkEvents

public void sinkEvents(int eventBitsToAdd)
Overrides:
sinkEvents in class Widget

ensureDomEventHandlers

protected void ensureDomEventHandlers()

onEnsureDebugId

protected void onEnsureDebugId(String baseID)
Affected Elements:

Overrides:
onEnsureDebugId in class UIObject
See Also:
UIObject.onEnsureDebugId(String)

onLoad

protected void onLoad()
This method is called when a widget is attached to the browser's document. onAttach needs special handling for the CheckBox case. Must still call Widget.onAttach() to preserve the onAttach contract.

Overrides:
onLoad in class Widget

onUnload

protected void onUnload()
This method is called when a widget is detached from the browser's document. Overridden because of IE bug that throws away checked state and in order to clear the event listener off of the inputElem.

Overrides:
onUnload in class Widget


Copyright © 2015. All rights reserved.