Class CheckBox

public class CheckBox
extends ButtonBase

// Superclass of RadioButton
A standard check box widget (also serves as a base class for RadioButton.

CSS Style Rules

Example

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 listener to find out when it's clicked.
    cb.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        boolean checked = ((CheckBox) sender).isChecked();
        Window.alert("It is " + (checked ? "" : "not") + "checked");
      }
    });

    // Add it to the root panel.
    RootPanel.get().add(cb);
  }
}

Constructors

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

Methods

getHTML()
getText()
isChecked()Determines whether this check box is currently checked.
isEnabled()Gets whether this widget is enabled.
setChecked(boolean)Checks or unchecks this check box.
setEnabled(boolean)Sets whether this widget is enabled.
setHTML(String)
setText(String)

Constructor Detail

CheckBox

public CheckBox()
Creates a check box with no label.

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, boolean asHTML)
Creates a check box with the specified text label.

Parameters

label
the check box's label
asHTML

CheckBox

protected CheckBox(Element elem)

Parameters

elem

Method Detail

getHTML

public String getHTML()

getText

public String getText()

isChecked

public boolean isChecked()
Determines whether this check box is currently checked.

Return Value

true if the check box is checked

isEnabled

public boolean isEnabled()
Gets whether this widget is enabled.

Return Value

true if the widget is enabled

setChecked

public void setChecked(boolean checked)
Checks or unchecks this check box.

Parameters

checked
true to check the check box

setEnabled

public void setEnabled(boolean enabled)
Sets whether this widget is enabled.

Parameters

enabled
true to enable the widget, false to disable it

setHTML

public void setHTML(String html)

Parameters

html

setText

public void setText(String text)

Parameters

text