public class Checkbox extends GeneratedVaadinCheckbox<Checkbox,Boolean> implements com.vaadin.flow.component.HasSize
vaadin-checkbox element.
Checkbox is a value component that can be checked or unchecked. The default value is unchecked.
Checkbox also has a indeterminate mode, see isIndeterminate() for
more info.
GeneratedVaadinCheckbox.ChangeEvent<R extends GeneratedVaadinCheckbox<R,?>>, GeneratedVaadinCheckbox.CheckedChangeEvent<R extends GeneratedVaadinCheckbox<R,?>>, GeneratedVaadinCheckbox.IndeterminateChangeEvent<R extends GeneratedVaadinCheckbox<R,?>>com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>| Constructor and Description |
|---|
Checkbox()
Default constructor.
|
Checkbox(boolean initialValue)
Constructs a checkbox with the initial value.
|
Checkbox(String labelText)
Constructs a checkbox with the initial label text.
|
Checkbox(String labelText,
boolean initialValue)
Constructs a checkbox with the initial value.
|
Checkbox(String label,
com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>> listener)
Constructs a checkbox with the initial label text and value change
listener.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getLabel()
Get the current label text.
|
boolean |
isAutofocus()
Get the state for the auto-focus property of the checkbox.
|
boolean |
isIndeterminate()
Get the indeterminate state of the checkbox.
|
void |
setAriaLabel(String ariaLabel)
Set the accessibility label of this checkbox.
|
void |
setAutofocus(boolean autofocus)
Set the checkbox to be input focused when the page loads.
|
void |
setIndeterminate(boolean indeterminate)
Set the indeterminate state of the checkbox.
|
void |
setLabel(String label)
Set the current label text of this checkbox.
|
void |
setLabelAsHtml(String htmlContent)
Set the current label text of this checkbox with HTML formatting.
|
addChangeListener, addCheckedChangeListener, addIndeterminateChangeListener, getNameString, isAutofocusBoolean, isDisabledBoolean, isIndeterminateBoolean, setDisabled, setNamegetSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventaddValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCssSize, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFulladdClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameaddFocusShortcut, blur, focus, getTabIndex, setTabIndexaddClickListener, addClickShortcutpublic Checkbox()
public Checkbox(String labelText)
labelText - the label text to setsetLabel(String)public Checkbox(boolean initialValue)
initialValue - the initial valueAbstractField.setValue(Object)public Checkbox(String labelText, boolean initialValue)
labelText - the label text to setinitialValue - the initial valuesetLabel(String),
AbstractField.setValue(Object)public Checkbox(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>> listener)
label - the label text to setlistener - the value change listener to addsetLabel(String),
HasValue.addValueChangeListener(ValueChangeListener)public String getLabel()
public void setLabel(String label)
label - the label text to setpublic void setLabelAsHtml(String htmlContent)
XSS vulnerability warning: the given HTML is rendered in the browser as is and the developer is responsible for ensuring no harmful HTML is used.
htmlContent - the label html to setpublic void setAriaLabel(String ariaLabel)
ariaLabel - the accessibility label to setpublic void setAutofocus(boolean autofocus)
setAutofocus in class GeneratedVaadinCheckbox<Checkbox,Boolean>autofocus - the boolean value to setpublic boolean isAutofocus()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
autofocus property from the checkboxpublic void setIndeterminate(boolean indeterminate)
NOTE: As according to the HTML5 standard, this has only effect on the visual appearance, not on the checked value!
setIndeterminate in class GeneratedVaadinCheckbox<Checkbox,Boolean>indeterminate - the boolean value to setisIndeterminate()public boolean isIndeterminate()
false.
An indeterminate checkbox is neither checked nor unchecked. A typical use
case is a “Select All” checkbox indicating that some, but not all, items
are selected. When the user clicks an indeterminate checkbox, it is no
longer indeterminate, and the checked value also changes.
NOTE: As according to the HTML5 standard, this has only effect on the visual appearance, not on the checked value!
indeterminate property from the checkboxCopyright © 2021. All rights reserved.