public class Checkbox extends GeneratedVaadinCheckbox<Checkbox,Boolean> implements HasSize, HasLabel
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,?>>
AbstractField.ComponentValueChangeEvent<C extends Component,V>
BlurNotifier.BlurEvent<C extends Component>
FocusNotifier.FocusEvent<C extends Component>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
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,
HasValue.ValueChangeListener<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, setName
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
getElement
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isEnabled, setEnabled
addClickListener, addClickShortcut
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
clear, getOptionalValue
addAttachListener
addDetachListener
public 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, HasValue.ValueChangeListener<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)
public 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 © 2023. All rights reserved.