Class SimpleCheckBox

All Implemented Interfaces:
IsEditor<LeafValueEditor<Boolean>>, HasAllDragAndDropHandlers, HasAllFocusHandlers, HasAllGestureHandlers, HasAllKeyHandlers, HasAllMouseHandlers, HasAllTouchHandlers, HasBlurHandlers, 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, EventListener, TakesValue<Boolean>, Focusable, HasEnabled, HasFocus, HasName, HasValue<Boolean>, HasVisibility, IsWidget, SourcesClickEvents, SourcesFocusEvents, SourcesKeyboardEvents, SourcesMouseEvents
Direct Known Subclasses:
SimpleRadioButton

public class SimpleCheckBox extends FocusWidget implements HasName, HasValue<Boolean>, IsEditor<LeafValueEditor<Boolean>>
A simple checkbox widget, with no label.

CSS Style Rules

  • .gwt-SimpleCheckBox { }
  • .gwt-SimpleCheckBox-disabled { Applied when checkbox is disabled }
  • Constructor Details

    • SimpleCheckBox

      public SimpleCheckBox()
      Creates a new simple checkbox.
    • SimpleCheckBox

      protected SimpleCheckBox(Element element)
      This constructor may be used by subclasses to explicitly use an existing element. This element must be an <input> element whose type is either 'checkbox'.
      Parameters:
      element - the element to be used
    • SimpleCheckBox

      SimpleCheckBox(Element element, String styleName)
  • Method Details

    • wrap

      public static SimpleCheckBox wrap(Element element)
      Creates a SimpleCheckBox widget that wraps an existing <input type='checkbox'> element. This element must already be attached to the document. If the element is removed from the document, you must call Widget.removeFromParent().
      Parameters:
      element - the element to be wrapped
    • addValueChangeHandler

      public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
      Description copied from interface: HasValueChangeHandlers
      Adds a ValueChangeEvent handler.
      Specified by:
      addValueChangeHandler in interface HasValueChangeHandlers<Boolean>
      Parameters:
      handler - the handler
      Returns:
      the registration for the event
    • asEditor

      public LeafValueEditor<Boolean> asEditor()
      Description copied from interface: IsEditor
      Returns the Editor encapsulated by the view object.
      Specified by:
      asEditor in interface IsEditor<LeafValueEditor<Boolean>>
      Returns:
      an Editor of type E
    • 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 check box 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.

    • getName

      public String getName()
      Description copied from interface: HasName
      Gets the widget's name.
      Specified by:
      getName in interface HasName
      Returns:
      the widget's name
    • 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 HasValue<Boolean>
      Specified by:
      getValue in interface TakesValue<Boolean>
      Returns:
      true if the check box is checked, false otherwise. Will not return null
      See Also:
    • isChecked

      @Deprecated public boolean isChecked()
      Deprecated.
      Use getValue() instead
      Determines whether this check box is currently checked.
      Returns:
      true if the check box is checked
    • setChecked

      @Deprecated public void setChecked(boolean checked)
      Deprecated.
      Use setValue(Boolean) instead
      Checks or unchecks this check box.
      Parameters:
      checked - true to check the check box
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from class: FocusWidget
      Sets whether this widget is enabled.
      Specified by:
      setEnabled in interface HasEnabled
      Overrides:
      setEnabled in class FocusWidget
      Parameters:
      enabled - true to enable the widget, false to disable it
    • 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 check box'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.

      Parameters:
      value -
    • setName

      public void setName(String name)
      Description copied from interface: HasName
      Sets the widget's name.
      Specified by:
      setName in interface HasName
      Parameters:
      name - the widget's new name
    • 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 HasValue<Boolean>
      Specified by:
      setValue in interface TakesValue<Boolean>
      Parameters:
      value - true to check, false to uncheck; null value implies false
      See Also:
    • 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
    • ensureDomEventHandlers

      protected void ensureDomEventHandlers()
    • 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.
      Overrides:
      onUnload in class Widget