|
GWT 2.0.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.FocusWidget
com.google.gwt.user.client.ui.ButtonBase
com.google.gwt.user.client.ui.CheckBox
public class CheckBox
A standard check box widget.
This class also serves as a base class for
RadioButton
.
public class CheckBoxExample implements EntryPoint { public void onModuleLoad() { // Make a new check box, and select it by default. CheckBox cb = new CheckBox("Foo"); cb.setChecked(true); // Hook up a handler to find out when it's clicked. cb.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { boolean checked = ((CheckBox) event.getSource()).isChecked(); Window.alert("It is " + (checked ? "" : "not ") + "checked"); } }); // Add it to the root panel. RootPanel.get().add(cb); } }
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
Field Summary |
---|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
|
CheckBox()
Creates a check box with no label. |
protected |
CheckBox(Element elem)
|
|
CheckBox(java.lang.String label)
Creates a check box with the specified text label. |
|
CheckBox(java.lang.String label,
boolean asHTML)
Creates a check box with the specified text label. |
Method Summary | |
---|---|
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<java.lang.Boolean> handler)
Adds a ValueChangeEvent handler. |
protected void |
ensureDomEventHandlers()
|
java.lang.String |
getFormValue()
Returns the value property of the input element that backs this widget. |
java.lang.String |
getHTML()
Gets this object's contents as HTML. |
java.lang.String |
getName()
Gets the widget's name. |
int |
getTabIndex()
Gets the tab index. |
java.lang.String |
getText()
Gets this object's text. |
java.lang.Boolean |
getValue()
Determines whether this check box is currently checked. |
boolean |
isChecked()
Deprecated. Use getValue() instead |
boolean |
isEnabled()
Gets whether this widget is enabled. |
protected void |
onEnsureDebugId(java.lang.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. |
void |
setAccessKey(char key)
Sets the widget's 'access key'. |
void |
setChecked(boolean checked)
Deprecated. Use setValue(Boolean) instead |
void |
setEnabled(boolean enabled)
Sets whether this widget is enabled. |
void |
setFocus(boolean focused)
Explicitly focus/unfocus this widget. |
void |
setFormValue(java.lang.String value)
Set the value property on the input element that backs this widget. |
void |
setHTML(java.lang.String html)
Sets this object's contents via HTML. |
void |
setName(java.lang.String name)
Sets the widget's name. |
void |
setTabIndex(int index)
Sets the widget's position in the tab index. |
void |
setText(java.lang.String text)
Sets this object's text. |
void |
setValue(java.lang.Boolean value)
Checks or unchecks the text box. |
void |
setValue(java.lang.Boolean value,
boolean fireEvents)
Checks or unchecks the text box, firing ValueChangeEvent if
appropriate. |
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. |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, removeFromParent, setLayoutData |
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, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents |
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 |
Constructor Detail |
---|
public CheckBox()
public CheckBox(java.lang.String label)
label
- the check box's labelpublic CheckBox(java.lang.String label, boolean asHTML)
label
- the check box's labelasHTML
- true
to treat the specified label as htmlprotected CheckBox(Element elem)
Method Detail |
---|
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.lang.Boolean> handler)
HasValueChangeHandlers
ValueChangeEvent
handler.
addValueChangeHandler
in interface HasValueChangeHandlers<java.lang.Boolean>
handler
- the handler
public java.lang.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 java.lang.String getHTML()
HasHTML
getHTML
in interface HasHTML
getHTML
in class ButtonBase
public java.lang.String getName()
HasName
getName
in interface HasName
public int getTabIndex()
FocusWidget
getTabIndex
in interface Focusable
getTabIndex
in class FocusWidget
public java.lang.String getText()
HasText
getText
in interface HasText
getText
in class ButtonBase
public java.lang.Boolean getValue()
Note that this is not return the value property of the checkbox
input element wrapped by this widget. For access to that property, see
getFormValue()
getValue
in interface HasValue<java.lang.Boolean>
true
if the check box is checked, false otherwise.
Will not return null@Deprecated public boolean isChecked()
getValue()
instead
true
if the check box is checkedpublic boolean isEnabled()
FocusWidget
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)
instead
ValueChangeEvent
.
(If you want the event to fire, use setValue(Boolean, boolean)
)
checked
- true
to check the check box.public void setEnabled(boolean enabled)
FocusWidget
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(java.lang.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(java.lang.String html)
HasHTML
HasText.setText(String)
whenever possible.
setHTML
in interface HasHTML
setHTML
in class ButtonBase
html
- the object's new HTMLpublic void setName(java.lang.String name)
HasName
setName
in interface HasName
name
- the widget's new namepublic 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(java.lang.String text)
HasText
setText
in interface HasText
setText
in class ButtonBase
text
- the object's new textpublic void setValue(java.lang.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 HasValue<java.lang.Boolean>
value
- true to check, false to uncheck; must not be null
java.lang.IllegalArgumentException
- if value is nullpublic void setValue(java.lang.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<java.lang.Boolean>
value
- true to check, false to uncheck; must not be nullfireEvents
- If true, and value has changed, fire a
ValueChangeEvent
java.lang.IllegalArgumentException
- if value is nullpublic 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(java.lang.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.
onLoad
in class Widget
protected void onUnload()
inputElem
.
onUnload
in class Widget
protected void replaceInputElement(Element elem)
RadioButton.setName(java.lang.String)
.)
elem
- the new input element
|
GWT 2.0.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |