1. Domino UI
  2. Forms
  3. Check box
Top Basic Docs

Basic checkbox

Represents a checkbox input field that allows users to select or deselect an option.

Example usage:

 
 CheckBox checkBox = CheckBox.create("Enable feature")
      .setChecked(true)
      .onChange(value -> DomGlobal.console.log("Checkbox state changed: " + value));
 

See also :

Examples

Basic Check box with different styles and tri-state.

API Docs: CheckBox

Constructors

public void CheckBox()
Initializes a new CheckBox instance.
public void CheckBox(String checkLabel)
Creates a CheckBox instance with a check label.

checkLabel

The label text displayed next to the checkbox.

public void CheckBox(String label, String checkLabel)
Creates a CheckBox instance with labels for both the checkbox field and the check label.

label

The label text for the checkbox field.

checkLabel

The label text displayed next to the checkbox.

Static methods

public static CheckBox create(String checkLabel)
Creates a CheckBox instance.

checkLabel

The label text displayed next to the checkbox.

public static CheckBox create(String label, String checkLabel)
Creates a CheckBox instance with an additional label.

label

The label text for the checkbox field.

checkLabel

The label text displayed next to the checkbox.

public static CheckBox create()
Creates a CheckBox instance without any labels.

Public methods

public Optional<Consumer<Event>> onChange()
Check super implementation documentation.

Returns an optional Consumer of Event that listens for change events on this CheckBox. When a change event occurs, this method checks if the CheckBox is enabled and not read-only. If both conditions are met, it updates the CheckBox's value based on its checked state.

Returns:

An optional Consumer of Event to handle change events on this CheckBox.

public CheckBox setCheckLabel(String checkLabel)
Sets the label text displayed next to the checkbox.

checkLabel

The label text for the checkbox.



Returns:

This CheckBox instance.

public CheckBox setCheckLabel(Node checkLabel)
Sets the label content displayed next to the checkbox using a DOM Node.

checkLabel

The DOM Node to be used as the label content.



Returns:

This CheckBox instance.

public CheckBox setCheckLabel(IsElement<?> checkLabel)
Sets the label content displayed next to the checkbox using an IsElement .

checkLabel

The IsElement to be used as the label content.



Returns:

This CheckBox instance.

public String getType()
Check super implementation documentation.

Gets the type of this input field, which is always "checkbox" for CheckBox instances.

Returns:

The type of this input field, which is "checkbox."

public CheckBox toggleChecked(boolean silent)
Toggles the checkbox's checked state, optionally without triggering change listeners.

silent

If true , change listeners will not be triggered; otherwise, they will.



Returns:

This CheckBox instance.

public CheckBox toggleChecked()
Toggles the checkbox's checked state and triggers change listeners.

Returns:

This CheckBox instance.

public CheckBox toggleChecked(boolean checkedState, boolean silent)
Toggles the checkbox's checked state, optionally without triggering change listeners.

checkedState

The desired checked state.

silent

If true , change listeners will not be triggered; otherwise, they will.



Returns:

This CheckBox instance.

public Boolean getDefaultValue()
Check super implementation documentation.

This method returns the default value for the CheckBox, which is false if no default value has been set.

Returns:

The default value of the CheckBox (false if not set).

public CheckBox withValue(Boolean value, boolean silent)
Check super implementation documentation.

This method sets the value of the CheckBox and allows the option to perform the operation silently (without triggering change listeners).

If the provided value is null , it will use the default value instead (if set).

value

The value to set.

silent

True to perform the operation silently, false otherwise.



Returns:

This CheckBox instance.

public CheckBox indeterminate()
Check super implementation documentation.

This method sets the CheckBox to an indeterminate state.

Returns:

This CheckBox instance.

public CheckBox determinate()
Check super implementation documentation.

This method sets the CheckBox to a determinate state.

Returns:

This CheckBox instance.

public CheckBox toggleIndeterminate(boolean indeterminate)
Check super implementation documentation.

This method toggles the indeterminate state of the CheckBox.

indeterminate

True to set to an indeterminate state, false otherwise.



Returns:

This CheckBox instance.

public CheckBox toggleIndeterminate()
Check super implementation documentation.

This method toggles the indeterminate state of the CheckBox.

Returns:

This CheckBox instance.

public CheckBox check()
Check super implementation documentation.

Checks the CheckBox, setting its value to true . If the CheckBox is currently paused for change listeners, the check operation can be silent. If not paused, it will trigger change listeners if any are registered.

Returns:

This CheckBox instance after the check operation.

public CheckBox uncheck()
Check super implementation documentation.

Unchecks the CheckBox, setting its value to false . If the CheckBox is currently paused for change listeners, the uncheck operation can be silent. If not paused, it will trigger change listeners if any are registered.

Returns:

This CheckBox instance after the uncheck operation.

public CheckBox check(boolean silent)
Check super implementation documentation.

This method checks the CheckBox, optionally allowing the operation to be performed silently (without triggering change listeners). It also sets the CheckBox to a determinate state.

silent

True to perform the operation silently, false otherwise.



Returns:

This CheckBox instance.

public CheckBox uncheck(boolean silent)
Check super implementation documentation.

This method unchecks the CheckBox, optionally allowing the operation to be performed silently (without triggering change listeners). It also sets the CheckBox to a determinate state.

silent

True to perform the operation silently, false otherwise.



Returns:

This CheckBox instance.

public boolean isChecked()
Check super implementation documentation.

This method checks whether the CheckBox is in a checked state.

Returns:

True if the CheckBox is checked, false otherwise.

public CheckBox filledIn()
Adds CSS class to style the CheckBox as filled in.

Returns:

This CheckBox instance.

public CheckBox filledOut()
Adds CSS class to style the CheckBox as filled out.

Returns:

This CheckBox instance.

public CheckBox setFilled(boolean filled)
Sets the filled state of the CheckBox, adding or removing the CSS class accordingly.

filled

True to style the CheckBox as filled in, false to style it as filled out.



Returns:

This CheckBox instance.

public Boolean getValue()
Check super implementation documentation.

This method returns the value of the CheckBox, which is the same as whether it's checked or not.

Returns:

True if the CheckBox is checked, false otherwise.

public boolean isEmpty()
Check super implementation documentation.

This method checks whether the CheckBox is empty, meaning it is not checked.

Returns:

True if the CheckBox is empty (unchecked), false otherwise.

public boolean isEmptyIgnoreSpaces()
Check super implementation documentation.

This method checks whether the CheckBox is empty, ignoring spaces.

Returns:

True if the CheckBox is empty (unchecked), false otherwise.

public String getStringValue()
Check super implementation documentation.

This method returns the string representation of the CheckBox's value, which is either "true" if checked or "false" if not checked.

Returns:

The string representation of the CheckBox's value.

public AutoValidator createAutoValidator(ApplyFunction autoValidate)
Check super implementation documentation.

This method creates an AutoValidator instance for the CheckBox, which is used to automatically validate the CheckBox's value.

autoValidate

The function to apply for auto-validation.



Returns:

An AutoValidator instance for the CheckBox.

public String getName()
Check super implementation documentation.

This method returns the name of the CheckBox.

Returns:

The name of the CheckBox.

public CheckBox setName(String name)
Check super implementation documentation.

This method sets the name attribute of the CheckBox's input element.

name

The name to set.



Returns:

This CheckBox instance.

public CheckBox withLabel(ChildHandler<CheckBox, LabelElement> handler)
Applies the given handler to the label element associated with this CheckBox. This allows you to customize the label element.

handler

The handler to apply to the label element.



Returns:

This CheckBox instance.

public CheckBox withLabelTextElement(ChildHandler<CheckBox, SpanElement> handler)
Applies the given handler to the label text element associated with this CheckBox. This allows you to customize the label text element.

handler

The handler to apply to the label text element.



Returns:

This CheckBox instance.

public LabelElement getCheckLabelElement()
Retrieves the label element associated with this CheckBox.

Returns:

The label element of this CheckBox.

public LazyChild<SpanElement> getCheckLabelTextElement()
Retrieves the lazy child element representing the label text associated with this CheckBox.

Returns:

The lazy child element of the label text associated with this CheckBox.

We are a group of passionate people who love what we do

Donate & Support Us