Class Slider
- All Implemented Interfaces:
AttachNotifier,BlurNotifier<Slider>,DetachNotifier,Focusable<Slider>,FocusNotifier<Slider>,HasAriaLabel,HasElement,HasEnabled,HasHelper,HasLabel,HasSize,HasStyle,HasValidation,HasValue<AbstractField.ComponentValueChangeEvent<Slider,,Double>, Double> HasValueAndElement<AbstractField.ComponentValueChangeEvent<Slider,,Double>, Double> KeyNotifier,HasTooltip,HasValidationProperties,InputField<AbstractField.ComponentValueChangeEvent<Slider,,Double>, Double> HasValueChangeMode,Serializable
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
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<?>> -
Field Summary
Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionSlider()Constructs aSliderwith min 0, max 100, and initial value 0.Slider(double min, double max, double value) Constructs aSliderwith the given min, max and initial value.Slider(double min, double max, double step, double value) Constructs aSliderwith the given min, max, step, and initial value.Slider(double min, double max, double step, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given min, max, step, initial value, and a value change listener.Slider(double min, double max, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given min, max, initial value, and a value change listener.Slider(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith min 0, max 100, initial value 0, and a value change listener.Constructs aSliderwith the given label, min 0, max 100, and initial value 0.Constructs aSliderwith the given label, min, max, and initial value.Constructs aSliderwith the given label, min, max, step, and initial value.Slider(String label, double min, double max, double step, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min, max, step, initial value, and a value change listener.Slider(String label, double min, double max, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min, max, initial value, and a value change listener.Slider(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min 0, max 100, initial value 0, and a value change listener. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the slider value, setting it to the minimum value.Gets the accessible name for the range input element of the slider.Gets the id of the element used as the accessible name for the range input element of the slider.doublegetMax()Gets the maximum value of the slider.doublegetMin()Gets the minimum value of the slider.doublegetStep()Gets the step value of the slider.Gets current value change mode of the component.intReturns the currently set timeout, for how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.protected booleanChecks whether the element property has a value that can be converted to the model type.booleanGets whether the min and max values are displayed below the slider track.booleanGets whether the value bubble is always visible, regardless of focus or hover state.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.voidsetAriaLabel(String ariaLabel) Sets an accessible name for the range input element of the slider.voidsetAriaLabelledBy(String ariaLabelledBy) Sets the id of an element to be used as the accessible name for the range input element of the slider.voidsetMax(double max) Sets the maximum value of the slider.voidsetMin(double min) Sets the minimum value of the slider.voidsetMinMaxVisible(boolean minMaxVisible) Sets whether the min and max values are displayed below the slider track.voidsetStep(double step) Sets the step value of the slider.voidSets the value of the slider.voidSets the minimum, maximum, and value of the slider atomically.voidSets the minimum, maximum, step, and value of the slider atomically.voidsetValueAlwaysVisible(boolean valueAlwaysVisible) Sets whether the value bubble is always visible, regardless of focus or hover state.voidsetValueChangeMode(ValueChangeMode valueChangeMode) Sets new value change mode for the component.voidsetValueChangeTimeout(int valueChangeTimeout) Sets how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
bindErrorMessage, bindInvalid, getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, bindValue, getEmptyValue, getOptionalValue, getValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisibleMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
Slider
public Slider()Constructs aSliderwith min 0, max 100, and initial value 0.The step defaults to 1.
-
Slider
public Slider(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith min 0, max 100, initial value 0, and a value change listener.The step defaults to 1.
- Parameters:
listener- the value change listener
-
Slider
public Slider(double min, double max, double value) Constructs aSliderwith the given min, max and initial value.The step defaults to 1.
- Parameters:
min- the minimum valuemax- the maximum valuevalue- the initial value
-
Slider
public Slider(double min, double max, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given min, max, initial value, and a value change listener.The step defaults to 1.
- Parameters:
min- the minimum valuemax- the maximum valuevalue- the initial valuelistener- the value change listener
-
Slider
public Slider(double min, double max, double step, double value) Constructs aSliderwith the given min, max, step, and initial value.- Parameters:
min- the minimum valuemax- the maximum valuestep- the step valuevalue- the initial value
-
Slider
public Slider(double min, double max, double step, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given min, max, step, initial value, and a value change listener.- Parameters:
min- the minimum valuemax- the maximum valuestep- the step valuevalue- the initial valuelistener- the value change listener
-
Slider
Constructs aSliderwith the given label, min 0, max 100, and initial value 0.The step defaults to 1.
- Parameters:
label- the text to set as the label
-
Slider
public Slider(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min 0, max 100, initial value 0, and a value change listener.The step defaults to 1.
- Parameters:
label- the text to set as the labellistener- the value change listener
-
Slider
Constructs aSliderwith the given label, min, max, and initial value.The step defaults to 1.
- Parameters:
label- the text to set as the labelmin- the minimum valuemax- the maximum valuevalue- the initial value
-
Slider
public Slider(String label, double min, double max, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min, max, initial value, and a value change listener.- Parameters:
label- the text to set as the labelmin- the minimum valuemax- the maximum valuevalue- the initial valuelistener- the value change listener
-
Slider
Constructs aSliderwith the given label, min, max, step, and initial value.- Parameters:
label- the text to set as the labelmin- the minimum valuemax- the maximum valuestep- the step valuevalue- the initial value
-
Slider
public Slider(String label, double min, double max, double step, double value, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min, max, step, initial value, and a value change listener.- Parameters:
label- the text to set as the labelmin- the minimum valuemax- the maximum valuestep- the step valuevalue- the initial valuelistener- the value change listener
-
-
Method Details
-
setAriaLabel
Sets an accessible name for the range input element of the slider.- Specified by:
setAriaLabelin interfaceHasAriaLabel- Parameters:
ariaLabel- the accessible name to set, ornullto remove it
-
getAriaLabel
Gets the accessible name for the range input element of the slider.- Specified by:
getAriaLabelin interfaceHasAriaLabel- Returns:
- an optional accessible name, or an empty optional if no accessible name has been set
-
setAriaLabelledBy
Sets the id of an element to be used as the accessible name for the range input element of the slider.- Specified by:
setAriaLabelledByin interfaceHasAriaLabel- Parameters:
ariaLabelledBy- the id of the element to be used as the label, ornullto remove it
-
getAriaLabelledBy
Gets the id of the element used as the accessible name for the range input element of the slider.- Specified by:
getAriaLabelledByin interfaceHasAriaLabel- Returns:
- an optional id of the element used as the label, or an empty optional if no id has been set
-
getMin
public double getMin()Gets the minimum value of the slider.- Returns:
- the minimum value
-
setMin
public void setMin(double min) Sets the minimum value of the slider.This method automatically clamps the current value to be no less than the new minimum, which may trigger a value change event. To set the value explicitly along with the new minimum, use the
method instead.invalid reference
setValue(value, min, max)- Parameters:
min- the minimum value- Throws:
IllegalArgumentException- if min is greater than the current max
-
getMax
public double getMax()Gets the maximum value of the slider.- Returns:
- the maximum value
-
setMax
public void setMax(double max) Sets the maximum value of the slider.This method automatically clamps the current value to be no greater than the new maximum, which may trigger a value change event. To set the value explicitly along with the new maximum, use the
method instead.invalid reference
setValue(value, min, max)- Parameters:
max- the maximum value- Throws:
IllegalArgumentException- if max is less than the current min
-
getStep
public double getStep()Gets the step value of the slider.Valid slider values are calculated relative to the minimum value:
min,min + step,min + 2*step, etc.- Returns:
- the step value
-
setStep
public void setStep(double step) Sets the step value of the slider.This method automatically adjusts the current value to be aligned with the new step, which may trigger a value change event. To set the value explicitly along with the new step, use the
method instead.invalid reference
setValue(value, min, max, step)- Parameters:
step- the step value- Throws:
IllegalArgumentException- if step is not positive
-
clear
public void clear()Clears the slider value, setting it to the minimum value. -
hasValidValue
protected boolean hasValidValue()Description copied from class:AbstractSinglePropertyFieldChecks whether the element property has a value that can be converted to the model type. Property changes from the element will be ignored if this method returnsfalse. The default implementation always returntrue.- Overrides:
hasValidValuein classAbstractSinglePropertyField<Slider,Double> - Returns:
trueif the element property value can be converted to the model type; otherwisefalse
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
AttachEventis fired for the component. Make sure to callsuper.onAttachwhen overriding this method. -
setValueAlwaysVisible
public void setValueAlwaysVisible(boolean valueAlwaysVisible) Sets whether the value bubble is always visible, regardless of focus or hover state. By default, bubble is hidden and only shown on interaction.- Parameters:
valueAlwaysVisible-trueto always show the value bubble,falseotherwise
-
isValueAlwaysVisible
public boolean isValueAlwaysVisible()Gets whether the value bubble is always visible, regardless of focus or hover state. By default, bubble is hidden and only shown on interaction.- Returns:
trueif the value bubble is always visible,falseotherwise
-
setMinMaxVisible
public void setMinMaxVisible(boolean minMaxVisible) Sets whether the min and max values are displayed below the slider track. By default, min and max values are hidden.- Parameters:
minMaxVisible-trueto display min and max values,falseotherwise
-
isMinMaxVisible
public boolean isMinMaxVisible()Gets whether the min and max values are displayed below the slider track. By default, min and max values are hidden.- Returns:
trueif the min and max values are displayed,falseotherwise
-
setValue
Sets the value of the slider.- Specified by:
setValuein interfaceHasValue<TComponent extends com.vaadin.flow.component.slider.SliderBase<TComponent,TValue>, TValue> - Overrides:
setValuein classAbstractField<TComponent extends com.vaadin.flow.component.slider.SliderBase<TComponent,TValue>, TValue> - Parameters:
value- the value- Throws:
IllegalArgumentException- if value is not valid for the current min, max and step
-
setValue
Sets the minimum, maximum, and value of the slider atomically.The step remains unchanged.
- Parameters:
value- the valuemin- the minimum valuemax- the maximum value- Throws:
IllegalArgumentException- if min is greater than maxIllegalArgumentException- if value is not valid for the given min, max and current step
-
setValue
Sets the minimum, maximum, step, and value of the slider atomically.- Parameters:
value- the valuemin- the minimum valuemax- the maximum valuestep- the step value- Throws:
IllegalArgumentException- if min is greater than maxIllegalArgumentException- if step is not positiveIllegalArgumentException- if value is not valid for the given min, max and step
-
getValueChangeMode
Gets current value change mode of the component.The default value is
ValueChangeMode.ON_CHANGE.- Specified by:
getValueChangeModein interfaceHasValueChangeMode- Returns:
- current value change mode of the component, or
nullif the value is not synchronized
-
setValueChangeMode
Description copied from interface:HasValueChangeModeSets new value change mode for the component.- Specified by:
setValueChangeModein interfaceHasValueChangeMode- Parameters:
valueChangeMode- new value change mode, ornullto disable the value synchronization
-
setValueChangeTimeout
public void setValueChangeTimeout(int valueChangeTimeout) Description copied from interface:HasValueChangeModeSets how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.Implementations should use
ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration).- Specified by:
setValueChangeTimeoutin interfaceHasValueChangeMode- Parameters:
valueChangeTimeout- the timeout in milliseconds of how oftenHasValue.ValueChangeEvents are triggered.
-
getValueChangeTimeout
public int getValueChangeTimeout()Description copied from interface:HasValueChangeModeReturns the currently set timeout, for how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.- Specified by:
getValueChangeTimeoutin interfaceHasValueChangeMode- Returns:
- the timeout in milliseconds of how often
HasValue.ValueChangeEvents are triggered.
-