Class IntegerSlider

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<IntegerSlider,Integer>
com.vaadin.flow.component.AbstractSinglePropertyField<IntegerSlider,Integer>
com.vaadin.flow.component.slider.IntegerSlider
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<IntegerSlider>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<IntegerSlider>, com.vaadin.flow.component.FocusNotifier<IntegerSlider>, com.vaadin.flow.component.HasAriaLabel, 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<IntegerSlider,Integer>,Integer>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<IntegerSlider,Integer>,Integer>, 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<IntegerSlider,Integer>,Integer>, com.vaadin.flow.data.value.HasValueChangeMode, Serializable

@Tag("vaadin-slider") @NpmPackage(value="@vaadin/slider", version="25.2.0-alpha8") @JsModule("@vaadin/slider/src/vaadin-slider.js") public class IntegerSlider extends com.vaadin.flow.component.AbstractSinglePropertyField<IntegerSlider,Integer>
IntegerSlider is an input field that allows the user to select a numeric value within a range by dragging a handle along a track or using arrow keys for precise input.

IntegerSlider uses Integer as the value type, see Slider for a version of the component that supports decimal values.

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<?>>
  • Field Summary

    Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode

    DEFAULT_CHANGE_TIMEOUT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an IntegerSlider with min 0 and max 100.
    IntegerSlider(int min, int max)
    Constructs an IntegerSlider with the given min and max.
    Constructs an IntegerSlider with the given label, min 0, and max 100.
    IntegerSlider(String label, int min, int max)
    Constructs an IntegerSlider with the given label, min and max.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.dom.SignalBinding<Integer>
    bindMax(com.vaadin.flow.signals.Signal<Integer> signal)
    Binds the given signal to the maximum value of the slider as a one-way binding so that the property is updated when the signal's value is updated.
    com.vaadin.flow.dom.SignalBinding<Integer>
    bindMin(com.vaadin.flow.signals.Signal<Integer> signal)
    Binds the given signal to the minimum value of the slider as a one-way binding so that the property is updated when the signal's value is updated.
    com.vaadin.flow.dom.SignalBinding<Integer>
    bindStep(com.vaadin.flow.signals.Signal<Integer> signal)
    Binds the given signal to the step value of the slider as a one-way binding so that the property is updated when the signal's value is updated.
    void
    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.
    Gets the maximum value of the slider.
    Gets the minimum value of the slider.
    Gets the step value of the slider.
    com.vaadin.flow.data.value.ValueChangeMode
    int
     
    protected boolean
     
    boolean
    Gets whether the min and max values are displayed below the slider track.
    protected boolean
     
    boolean
    Gets whether the value bubble is always visible, regardless of focus or hover state.
    protected boolean
     
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    void
    setAriaLabel(String ariaLabel)
    Sets an accessible name for the range input element of the slider.
    void
    setAriaLabelledBy(String ariaLabelledBy)
    Sets the id of an element to be used as the accessible name for the range input element of the slider.
    void
    Sets the maximum value of the slider.
    void
    Sets the minimum value of the slider.
    void
    setMinMaxVisible(boolean minMaxVisible)
    Sets whether the min and max values are displayed below the slider track.
    void
    Sets the step value of the slider.
    void
     
    void
    setValueAlwaysVisible(boolean valueAlwaysVisible)
    Sets whether the value bubble is always visible, regardless of focus or hover state.
    void
    setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
     
    void
    setValueChangeTimeout(int valueChangeTimeout)
     

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, setPresentationValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, valueEquals

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, 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.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasHelper

    bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperText

    Methods inherited from interface com.vaadin.flow.component.HasLabel

    getLabel, setLabel

    Methods 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, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipMarkdown, setTooltipText

    Methods inherited from interface com.vaadin.flow.component.HasValidation

    setManualValidation

    Methods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties

    getErrorMessage, isInvalid, setErrorMessage, setInvalid

    Methods inherited from interface com.vaadin.flow.component.HasValue

    addValueChangeListener, bindValue, getEmptyValue, getOptionalValue, getValue, isEmpty

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible

    Methods inherited from interface com.vaadin.flow.component.KeyNotifier

    addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
  • Constructor Details

    • IntegerSlider

      public IntegerSlider()
      Constructs an IntegerSlider with min 0 and max 100. The initial value is 0.

      The step defaults to 1.

    • IntegerSlider

      public IntegerSlider(int min, int max)
      Constructs an IntegerSlider with the given min and max. The initial value is set to the minimum value.

      The step defaults to 1.

      Parameters:
      min - the minimum value
      max - the maximum value
    • IntegerSlider

      public IntegerSlider(String label)
      Constructs an IntegerSlider with the given label, min 0, and max 100. The initial value is 0.

      The step defaults to 1.

      Parameters:
      label - the text to set as the label
    • IntegerSlider

      public IntegerSlider(String label, int min, int max)
      Constructs an IntegerSlider with the given label, min and max. The initial value is set to the minimum value.

      The step defaults to 1.

      Parameters:
      label - the text to set as the label
      min - the minimum value
      max - the maximum value
  • Method Details

    • setAriaLabel

      public void setAriaLabel(String ariaLabel)
      Sets an accessible name for the range input element of the slider.
      Specified by:
      setAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
      Parameters:
      ariaLabel - the accessible name to set, or null to remove it
    • getAriaLabel

      public Optional<String> getAriaLabel()
      Gets the accessible name for the range input element of the slider.
      Specified by:
      getAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
      Returns:
      an optional accessible name, or an empty optional if no accessible name has been set
    • setAriaLabelledBy

      public void setAriaLabelledBy(String ariaLabelledBy)
      Sets the id of an element to be used as the accessible name for the range input element of the slider.
      Specified by:
      setAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
      Parameters:
      ariaLabelledBy - the id of the element to be used as the label, or null to remove it
    • getAriaLabelledBy

      public Optional<String> getAriaLabelledBy()
      Gets the id of the element used as the accessible name for the range input element of the slider.
      Specified by:
      getAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
      Returns:
      an optional id of the element used as the label, or an empty optional if no id has been set
    • clear

      public void clear()
      Clears the slider value, setting it to the minimum value.
      Specified by:
      clear in interface com.vaadin.flow.component.HasValue<TComponent extends com.vaadin.flow.component.slider.NumberSlider<TComponent,TValue>,TValue extends Number>
      See Also:
    • isValueWithinMinMax

      protected boolean isValueWithinMinMax(Integer value)
    • isValueAlignedWithStep

      protected boolean isValueAlignedWithStep(Integer value)
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • getMin

      public Integer getMin()
      Gets the minimum value of the slider.
      Returns:
      the minimum value
    • setMin

      public void setMin(Integer min)
      Sets the minimum value of the slider.
      Parameters:
      min - the minimum value
    • getMax

      public Integer getMax()
      Gets the maximum value of the slider.
      Returns:
      the maximum value
    • setMax

      public void setMax(Integer max)
      Sets the maximum value of the slider.
      Parameters:
      max - the maximum value
    • getStep

      public Integer 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(Integer step)
      Sets the step value of the slider.

      Valid slider values are calculated relative to the minimum value: min, min + step, min + 2*step, etc.

      Parameters:
      step - the step value
    • bindMin

      public com.vaadin.flow.dom.SignalBinding<Integer> bindMin(com.vaadin.flow.signals.Signal<Integer> signal)
      Binds the given signal to the minimum value of the slider as a one-way binding so that the property is updated when the signal's value is updated.

      The minimum value is set immediately with the current signal value when the binding is created, and is kept synchronized with any subsequent signal value changes while the component is in attached state. When the component is in detached state, signal value changes have no effect.

      While a signal is bound, any attempt to set the minimum value manually through the setter throws a BindingActiveException.

      Parameters:
      signal - the signal to bind the minimum value to, not null
      Returns:
      a SignalBinding that can be used to register onChange callbacks
      Since:
      25.1
      See Also:
      • Element.bindProperty(String, Signal, SerializableConsumer)
    • bindMax

      public com.vaadin.flow.dom.SignalBinding<Integer> bindMax(com.vaadin.flow.signals.Signal<Integer> signal)
      Binds the given signal to the maximum value of the slider as a one-way binding so that the property is updated when the signal's value is updated.

      The maximum value is set immediately with the current signal value when the binding is created, and is kept synchronized with any subsequent signal value changes while the component is in attached state. When the component is in detached state, signal value changes have no effect.

      While a signal is bound, any attempt to set the maximum value manually through the setter throws a BindingActiveException.

      Parameters:
      signal - the signal to bind the maximum value to, not null
      Returns:
      a SignalBinding that can be used to register onChange callbacks
      Since:
      25.1
      See Also:
      • Element.bindProperty(String, Signal, SerializableConsumer)
    • bindStep

      public com.vaadin.flow.dom.SignalBinding<Integer> bindStep(com.vaadin.flow.signals.Signal<Integer> signal)
      Binds the given signal to the step value of the slider as a one-way binding so that the property is updated when the signal's value is updated.

      The step value is set immediately with the current signal value when the binding is created, and is kept synchronized with any subsequent signal value changes while the component is in attached state. When the component is in detached state, signal value changes have no effect.

      While a signal is bound, any attempt to set the step value manually through the setter throws a BindingActiveException.

      Parameters:
      signal - the signal to bind the step value to, not null
      Returns:
      a SignalBinding that can be used to register onChange callbacks
      Since:
      25.1
      See Also:
      • Element.bindProperty(String, Signal, SerializableConsumer)
    • 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 - true to always show the value bubble, false otherwise
    • 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:
      true if the value bubble is always visible, false otherwise
    • 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 - true to display min and max values, false otherwise
    • 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:
      true if the min and max values are displayed, false otherwise
    • getValueChangeMode

      public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()

      The default value is ValueChangeMode.ON_CHANGE.

      Specified by:
      getValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
    • setValueChangeMode

      public void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
      Specified by:
      setValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
    • setValueChangeTimeout

      public void setValueChangeTimeout(int valueChangeTimeout)
      Specified by:
      setValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeMode
    • getValueChangeTimeout

      public int getValueChangeTimeout()
      Specified by:
      getValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeMode
    • setValue

      public void setValue(Integer value)
      Specified by:
      setValue in interface com.vaadin.flow.component.HasValue<TComponent extends com.vaadin.flow.component.slider.SliderBase<TComponent,TValue,TNumber,TPresentation>,TValue>
      Overrides:
      setValue in class com.vaadin.flow.component.AbstractField<TComponent extends com.vaadin.flow.component.slider.SliderBase<TComponent,TValue,TNumber,TPresentation>,TValue>
    • hasValidValue

      protected boolean hasValidValue()
      Overrides:
      hasValidValue in class com.vaadin.flow.component.AbstractSinglePropertyField<TComponent extends com.vaadin.flow.component.slider.SliderBase<TComponent,TValue,TNumber,TPresentation>,TValue>