public class CheckBox extends ButtonBase implements HasName, HasValue<Boolean>, HasWordWrap, HasDirectionalSafeHtml, HasDirectionEstimator, IsEditor<LeafValueEditor<Boolean>>
RadioButton
.
setDirectionEstimator(boolean)
or
passing a DirectionEstimator parameter to the constructor, and is off by
default.
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
Modifier and Type | Field and Description |
---|---|
static DirectionEstimator |
DEFAULT_DIRECTION_ESTIMATOR |
DEBUG_ID_PREFIX
Modifier | Constructor and Description |
---|---|
|
CheckBox()
Creates a check box with no label.
|
protected |
CheckBox(Element elem) |
|
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.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<Boolean> handler)
Adds a
ValueChangeEvent handler. |
LeafValueEditor<Boolean> |
asEditor()
Returns the Editor encapsulated by the view object.
|
protected void |
ensureDomEventHandlers() |
DirectionEstimator |
getDirectionEstimator()
Returns the
DirectionEstimator object. |
String |
getFormValue()
Returns the value property of the input element that backs this widget.
|
String |
getHTML()
Gets this object's contents as HTML.
|
String |
getName()
Gets the widget's name.
|
int |
getTabIndex()
Gets the tab index.
|
String |
getText()
Gets this object's text.
|
HasDirection.Direction |
getTextDirection()
Gets the direction of this object's text.
|
Boolean |
getValue()
Determines whether this check box is currently checked.
|
boolean |
getWordWrap()
Gets whether word-wrapping is enabled.
|
boolean |
isChecked()
Deprecated.
Use
getValue() instead |
boolean |
isEnabled()
Gets whether this widget is enabled.
|
protected void |
onEnsureDebugId(String baseID)
Affected Elements:
-label = label next to 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.
|
protected void |
replaceInputElement(Element elem)
Replace the current input element with a new one.
|
protected void |
replaceInputElement(Element elem)
Deprecated.
Call and use
replaceInputElement(Element) instead. |
void |
setAccessKey(char key)
Sets the widget's 'access key'.
|
void |
setChecked(boolean checked)
Deprecated.
Use
setValue(Boolean) instead |
void |
setDirectionEstimator(boolean enabled)
Toggles on / off direction estimation.
|
void |
setDirectionEstimator(DirectionEstimator directionEstimator)
Sets the
DirectionEstimator object. |
void |
setEnabled(boolean enabled)
Sets whether this widget is enabled.
|
void |
setFocus(boolean focused)
Explicitly focus/unfocus this widget.
|
void |
setFormValue(String value)
Set the value property on the input element that backs this widget.
|
void |
setHTML(SafeHtml html,
HasDirection.Direction dir)
Sets this object's html, also declaring its direction.
|
void |
setHTML(String html)
Sets this object's contents via HTML.
|
void |
setName(String name)
Sets the widget's name.
|
void |
setTabIndex(int index)
Sets the widget's position in the tab index.
|
void |
setText(String text)
Sets this object's text.
|
void |
setText(String text,
HasDirection.Direction dir)
Sets this object's text, also declaring its direction.
|
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)
Sets whether word-wrapping is enabled.
|
void |
sinkEvents(int eventBitsToAdd)
Overridden to defer the call to super.sinkEvents until the first time this
widget is attached to the dom, as a performance enhancement.
|
setHTML
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
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, removeFromParent, setLayoutData, unsinkEvents
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
fireEvent
setHTML
public static final DirectionEstimator DEFAULT_DIRECTION_ESTIMATOR
public CheckBox()
public CheckBox(SafeHtml label)
label
- the check box's labelpublic CheckBox(SafeHtml label, HasDirection.Direction dir)
label
- the check box's labeldir
- the text's direction. Note that DEFAULT
means direction
should be inherited from the widget's parent element.public CheckBox(SafeHtml label, DirectionEstimator directionEstimator)
label
- the check box's labeldirectionEstimator
- A DirectionEstimator object used for automatic
direction adjustment. For convenience,
DEFAULT_DIRECTION_ESTIMATOR
can be used.public CheckBox(String label)
label
- the check box's labelpublic CheckBox(String label, HasDirection.Direction dir)
label
- the check box's labeldir
- the text's direction. Note that DEFAULT
means direction
should be inherited from the widget's parent element.public CheckBox(String label, DirectionEstimator directionEstimator)
label
- the check box's labeldirectionEstimator
- A DirectionEstimator object used for automatic
direction adjustment. For convenience,
DEFAULT_DIRECTION_ESTIMATOR
can be used.public CheckBox(String label, boolean asHTML)
label
- the check box's labelasHTML
- true
to treat the specified label as htmlprotected CheckBox(Element elem)
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
HasValueChangeHandlers
ValueChangeEvent
handler.addValueChangeHandler
in interface HasValueChangeHandlers<Boolean>
handler
- the handlerpublic LeafValueEditor<Boolean> asEditor()
IsEditor
asEditor
in interface IsEditor<LeafValueEditor<Boolean>>
Editor
of type Epublic DirectionEstimator getDirectionEstimator()
HasDirectionEstimator
DirectionEstimator
object.getDirectionEstimator
in interface HasDirectionEstimator
public String getFormValue()
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.
public String getHTML()
HasHTML
getHTML
in interface HasHTML
getHTML
in class ButtonBase
public int getTabIndex()
FocusWidget
getTabIndex
in interface Focusable
getTabIndex
in class FocusWidget
public String getText()
HasText
getText
in interface HasText
getText
in class ButtonBase
public HasDirection.Direction getTextDirection()
HasDirectionalText
getTextDirection
in interface HasDirectionalText
public Boolean getValue()
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()
getValue
in interface TakesValue<Boolean>
getValue
in interface HasValue<Boolean>
true
if the check box is checked, false otherwise.
Will not return nullTakesValue.setValue(V)
public boolean getWordWrap()
HasWordWrap
getWordWrap
in interface HasWordWrap
true
if word-wrapping is enabled.@Deprecated public boolean isChecked()
getValue()
insteadtrue
if the check box is checkedpublic boolean isEnabled()
FocusWidget
isEnabled
in interface HasEnabled
isEnabled
in class FocusWidget
true
if the widget is enabledpublic void setAccessKey(char key)
Focusable
setAccessKey
in interface Focusable
setAccessKey
in class FocusWidget
key
- the widget's access key@Deprecated public void setChecked(boolean checked)
setValue(Boolean)
insteadValueChangeEvent
.
(If you want the event to fire, use setValue(Boolean, boolean)
)checked
- true
to check the check box.public void setDirectionEstimator(boolean enabled)
See note at setDirectionEstimator(DirectionEstimator)
.
setDirectionEstimator
in interface HasDirectionEstimator
enabled
- Whether to enable direction estimation. If true
,
sets the DirectionEstimator
object to a default
DirectionEstimator
.public void setDirectionEstimator(DirectionEstimator directionEstimator)
DirectionEstimator
object.
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.
setDirectionEstimator
in interface HasDirectionEstimator
directionEstimator
- The DirectionEstimator
to be set. null
means turning off direction estimation.public void setEnabled(boolean enabled)
FocusWidget
setEnabled
in interface HasEnabled
setEnabled
in class FocusWidget
enabled
- true
to enable the widget, false
to disable itpublic void setFocus(boolean focused)
Focusable
setFocus
in interface Focusable
setFocus
in class FocusWidget
focused
- whether this widget should take focus or release itpublic void setFormValue(String value)
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.
value
- public void setHTML(SafeHtml html, HasDirection.Direction dir)
HasDirectionalSafeHtml
setHTML
in interface HasDirectionalSafeHtml
html
- the object's new htmldir
- the html's directionpublic void setHTML(String html)
HasHTML
HasText.setText(String)
whenever possible.setHTML
in interface HasHTML
setHTML
in class ButtonBase
html
- the object's new HTMLpublic void setName(String name)
HasName
public void setTabIndex(int index)
Focusable
-1
will cause this widget to
be removed from the tab order.setTabIndex
in interface Focusable
setTabIndex
in class FocusWidget
index
- the widget's tab indexpublic void setText(String text)
HasText
setText
in interface HasText
setText
in class ButtonBase
text
- the object's new textpublic void setText(String text, HasDirection.Direction dir)
HasDirectionalText
setText
in interface HasDirectionalText
text
- the object's new textdir
- the text's directionpublic void setValue(Boolean value)
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)
setValue
in interface TakesValue<Boolean>
setValue
in interface HasValue<Boolean>
value
- true to check, false to uncheck; null value implies falseTakesValue.getValue()
public void setValue(Boolean value, boolean fireEvents)
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)
setValue
in interface HasValue<Boolean>
value
- true to check, false to uncheck; null value implies falsefireEvents
- If true, and value has changed, fire a
ValueChangeEvent
public void setWordWrap(boolean wrap)
HasWordWrap
setWordWrap
in interface HasWordWrap
wrap
- true
to enable word-wrapping.public void sinkEvents(int eventBitsToAdd)
Widget
isOrWasAttached()
:
@Override public void sinkEvents(int eventBitsToAdd) { if (isOrWasAttached()) { / * customized sink code goes here */ } else { super.sinkEvents(eventBitsToAdd); } }
sinkEvents
in class Widget
eventBitsToAdd
- a bitfield representing the set of events to be added
to this element's event setEvent
protected void ensureDomEventHandlers()
protected void onEnsureDebugId(String baseID)
onEnsureDebugId
in class UIObject
baseID
- the base ID used by the main elementUIObject.onEnsureDebugId(String)
protected void onLoad()
Widget.onAttach()
to preserve the onAttach
contract.protected void onUnload()
inputElem
.protected void replaceInputElement(Element elem)
RadioButton.setName(java.lang.String)
.)elem
- the new input element@Deprecated protected void replaceInputElement(Element elem)
replaceInputElement(Element)
instead.Copyright © 2018. All rights reserved.