Class Slider
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<Slider>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<Slider>,com.vaadin.flow.component.FocusNotifier<Slider>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Slider,,Double>, Double> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Slider,,Double>, Double> com.vaadin.flow.component.KeyNotifier,com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Slider,,Double>, Double> Serializable
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given min, max, initial value, and a value change listener.Slider(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<Slider, Double>> listener) Constructs aSliderwith the given label, min, max, initial value, and a value change listener.Slider(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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.doublegetMax()Gets the maximum value of the slider.doublegetMin()Gets the minimum value of the slider.doublegetStep()Gets the step value of the slider.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidsetMax(double max) Sets the maximum value of the slider.voidsetMin(double min) Sets the minimum value of the slider.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.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, 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.HasLabel
getLabel, setLabelMethods 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(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.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
-
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.If the current value is less than the new minimum, it's automatically clamped, which triggers a value change event. To set both the minimum and value explicitly, 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.If the current value is greater than the new maximum, it's automatically clamped, which triggers a value change event. To set both the maximum and value explicitly, 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.If the current value is not aligned with the new step, it's automatically adjusted to the nearest value that matches the step, which triggers a value change event. To set both the step and value explicitly, 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.- See Also:
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
setValue
Sets the value of the slider.- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<TComponent extends com.vaadin.flow.component.slider.SliderBase<TComponent,TValue>, TValue> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<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
-