com.vaadin.flow.component.checkbox.
Class Checkbox
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<C,T>
-
- com.vaadin.flow.component.AbstractSinglePropertyField<R,T>
-
- com.vaadin.flow.component.checkbox.GeneratedVaadinCheckbox<Checkbox,Boolean>
-
- com.vaadin.flow.component.checkbox.Checkbox
-
All Implemented Interfaces:
AttachNotifier, BlurNotifier<Checkbox>, ClickNotifier<Checkbox>, DetachNotifier, Focusable<Checkbox>, FocusNotifier<Checkbox>, HasElement, HasEnabled, HasLabel, HasSize, HasStyle, HasValue<AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>,Boolean>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>,Boolean>, Serializable
public class Checkbox extends GeneratedVaadinCheckbox<Checkbox,Boolean> implements HasSize, HasLabel
Server-side component for the
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.Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.checkbox.GeneratedVaadinCheckbox
GeneratedVaadinCheckbox.ChangeEvent<R extends GeneratedVaadinCheckbox<R,?>>, GeneratedVaadinCheckbox.CheckedChangeEvent<R extends GeneratedVaadinCheckbox<R,?>>, GeneratedVaadinCheckbox.IndeterminateChangeEvent<R extends GeneratedVaadinCheckbox<R,?>>
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
AbstractField.ComponentValueChangeEvent<C extends Component,V>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
-
-
Constructor Summary
Constructors 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.
-
Method Summary
All Methods 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.
-
Methods inherited from class com.vaadin.flow.component.checkbox.GeneratedVaadinCheckbox
addChangeListener, addCheckedChangeListener, addIndeterminateChangeListener, getNameString, isAutofocusBoolean, isDisabledBoolean, isIndeterminateBoolean, setDisabled, setName
-
Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
-
Methods inherited from class com.vaadin.flow.component.Component
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.HasSize
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
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
-
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
-
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut
-
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
-
Methods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValue
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
-
-
-
Constructor Detail
-
Checkbox
public Checkbox()
Default constructor.
-
Checkbox
public Checkbox(String labelText)
Constructs a checkbox with the initial label text.
Parameters:
labelText
- the label text to setSee Also:
-
Checkbox
public Checkbox(boolean initialValue)
Constructs a checkbox with the initial value.
Parameters:
initialValue
- the initial valueSee Also:
-
Checkbox
public Checkbox(String labelText, boolean initialValue)
Constructs a checkbox with the initial value.
Parameters:
labelText
- the label text to setinitialValue
- the initial valueSee Also:
-
Checkbox
public Checkbox(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>> listener)
Constructs a checkbox with the initial label text and value change listener.
Parameters:
label
- the label text to setlistener
- the value change listener to addSee Also:
setLabel(String)
,HasValue.addValueChangeListener(ValueChangeListener)
-
-
Method Detail
-
getLabel
public String getLabel()
Get the current label text.
-
setLabel
public void setLabel(String label)
Set the current label text of this checkbox.
-
setLabelAsHtml
public void setLabelAsHtml(String htmlContent)
Set the current label text of this checkbox with HTML formatting.
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.
Parameters:
htmlContent
- the label html to set
-
setAriaLabel
public void setAriaLabel(String ariaLabel)
Set the accessibility label of this checkbox.
Parameters:
ariaLabel
- the accessibility label to setSee Also:
-
setAutofocus
public void setAutofocus(boolean autofocus)
Set the checkbox to be input focused when the page loads.
Overrides:
setAutofocus
in classGeneratedVaadinCheckbox<Checkbox,Boolean>
Parameters:
autofocus
- the boolean value to set
-
isAutofocus
public boolean isAutofocus()
Get the state for the auto-focus property of the checkbox.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
Returns:
the
autofocus
property from the checkbox
-
setIndeterminate
public void setIndeterminate(boolean indeterminate)
Set the indeterminate state of the checkbox.
NOTE: As according to the HTML5 standard, this has only effect on the visual appearance, not on the checked value!
Overrides:
setIndeterminate
in classGeneratedVaadinCheckbox<Checkbox,Boolean>
Parameters:
indeterminate
- the boolean value to setSee Also:
-
isIndeterminate
public boolean isIndeterminate()
Get the indeterminate state of the checkbox. The default value is
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!
Returns:
the
indeterminate
property from the checkbox
-
-