Class SJSlider

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

public class SJSlider extends com.vaadin.flow.component.slider.IntegerSlider implements JComponentMixin
Surrogate for JSlider (SD_sjslider). Extends Vaadin IntegerSlider directly (is-a) so it reaches the migrator either through the :emulators JSlider as peer, or as a richer-than-stock Vaadin component in its own right.

Vaadin's typed IntegerSlider (value type Integer) is the natural peer for JSlider's int-valued model — a Double-typed peer would need lossy casts on every value/min/max push.

Model flow (reused from :emulators.JSlider under SD_sjslider)

The installed BoundedRangeModel is the source of truth. A single ChangeListener on the model fans out to user ChangeListeners and pushes value changes to the peer (this Slider's own element) under the preventPeerEvents R_swing_is_truth guard. The peer's ValueChangeListener mirrors browser-originated edits back into the model via SHelper.callSwing(Runnable) (R_callswing_envelope seam); the resulting model ChangeEvent re-enters fanOutModelChange(), hits the preventPeerEvents guard, and only the Swing-side fan-out runs — no second peer write.

CSS-only rendering (orientation / inverted)

VERTICAL rotates the host element -90deg. inverted flips the horizontal axis via scaleX(-1). Combinations compose through applyTransformCss() — a single transform rule per setter so neither knob leaks the other's state when changed.

Server-side snapping (snapToTicks)

When snapToTicks is enabled and a non-zero tick spacing is installed, browser-originated values round to the nearest tick before reaching the model. minorTickSpacing wins over majorTickSpacing when both are set — matches JDK JSlider's snap priority.

Deferred rendering (upstream ticket)

Tick marks, value labels, and track-hiding all need addressable CSS parts or slots on vaadin-slider that the component doesn't currently expose. Filed as vaadin/flow-components#9181. Until upstream lands, setPaintTicks(boolean), setPaintLabels(boolean), setPaintTrack(boolean), setLabelTable(Dictionary), and createStandardLabels(int) field-round-trip, fire their PCE, but log a WARN on visual-effect arguments (true / non-null). The deferral is scoped to rendering only — snapToTicks and the tick-spacing fields work for their non-visual uses (snap logic, BeanInfo introspection).
See Also:
  • Constructor Details

    • SJSlider

      public SJSlider()
    • SJSlider

      public SJSlider(int orientation)
    • SJSlider

      public SJSlider(int min, int max)
    • SJSlider

      public SJSlider(int min, int max, int value)
    • SJSlider

      public SJSlider(int orientation, int min, int max, int value)
    • SJSlider

      public SJSlider(BoundedRangeModel brm)
  • Method Details

    • setValue

      public void setValue(int n)
      Int-valued setValue — overload of IntegerSlider's inherited setValue(Integer). Routes through the model so the single ChangeListener path handles both user-code mutations and peer-originated ones.
    • getMinimum

      public int getMinimum()
    • setMinimum

      public void setMinimum(int minimum)
    • getMaximum

      public int getMaximum()
    • setMaximum

      public void setMaximum(int maximum)
    • getExtent

      public int getExtent()
    • setExtent

      public void setExtent(int extent)
    • getValueIsAdjusting

      public boolean getValueIsAdjusting()
    • setValueIsAdjusting

      public void setValueIsAdjusting(boolean b)
    • getModel

      public BoundedRangeModel getModel()
    • setModel

      public void setModel(BoundedRangeModel newModel)
    • getOrientation

      public int getOrientation()
    • setOrientation

      public void setOrientation(int orientation)
    • getInverted

      public boolean getInverted()
    • setInverted

      public void setInverted(boolean b)
    • getMajorTickSpacing

      public int getMajorTickSpacing()
    • setMajorTickSpacing

      public void setMajorTickSpacing(int n)
    • getMinorTickSpacing

      public int getMinorTickSpacing()
    • setMinorTickSpacing

      public void setMinorTickSpacing(int n)
    • getSnapToTicks

      public boolean getSnapToTicks()
    • setSnapToTicks

      public void setSnapToTicks(boolean b)
    • getPaintTicks

      public boolean getPaintTicks()
    • setPaintTicks

      public void setPaintTicks(boolean b)
    • getPaintTrack

      public boolean getPaintTrack()
    • setPaintTrack

      public void setPaintTrack(boolean b)
    • getPaintLabels

      public boolean getPaintLabels()
    • setPaintLabels

      public void setPaintLabels(boolean b)
    • getLabelTable

      public Dictionary getLabelTable()
    • setLabelTable

      public void setLabelTable(Dictionary labels)
    • createStandardLabels

      public Hashtable createStandardLabels(int increment)
      JDK builds a Hashtable of JLabel-per-major-tick. Rendering is deferred (see class-level note); return an empty table so callers iterating it don't NPE. Raw type matches JDK's own signature.
    • createStandardLabels

      public Hashtable createStandardLabels(int increment, int start)
      Two-arg overload. Same deferral as createStandardLabels(int).
    • addChangeListener

      public void addChangeListener(ChangeListener l)
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
    • getChangeListeners

      public ChangeListener[] getChangeListeners()
    • fireStateChanged

      protected void fireStateChanged()
    • createChangeListener

      protected ChangeListener createChangeListener()
      JDK hook for subclasses that want to swap the model-attached listener. We allocate modelListener directly in installModel(BoundedRangeModel); an override wouldn't reach our code path today, but we expose this so a migrated subclass can call super.createChangeListener() and get the real listener.
    • getUIClassID

      public String getUIClassID()
      JDK JSlider returns "SliderUI". We don't drive a pluggable ComponentUI (R_layouts_close_enough — Vaadin owns the DOM), but keep the ID so migrated code that introspects via BeanInfo still finds the expected value.
      Specified by:
      getUIClassID in interface JComponentMixin
    • setAriaLabel

      public void setAriaLabel(String arg0)
      Specified by:
      setAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
    • getAriaLabel

      public Optional<String> getAriaLabel()
      Specified by:
      getAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
    • setAriaLabelledBy

      public void setAriaLabelledBy(String arg0)
      Specified by:
      setAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
    • getAriaLabelledBy

      public Optional<String> getAriaLabelledBy()
      Specified by:
      getAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
    • setAriaDescribedBy

      public void setAriaDescribedBy(String arg0)
      Specified by:
      setAriaDescribedBy in interface com.vaadin.flow.component.HasAriaDescription
    • getAriaDescribedBy

      public Optional<String> getAriaDescribedBy()
      Specified by:
      getAriaDescribedBy in interface com.vaadin.flow.component.HasAriaDescription
    • clear

      public void clear()
      Specified by:
      clear in interface com.vaadin.flow.component.HasValue<TComponent extends com.vaadin.flow.component.slider.NumberSlider<TComponent, TValue>, TValue extends Number>
    • isValueWithinMinMax

      protected boolean isValueWithinMinMax(Integer arg0)
    • isValueAlignedWithStep

      protected boolean isValueAlignedWithStep(Integer arg0)
    • getMin

      public Integer getMin()
    • setMin

      public void setMin(Integer arg0)
    • getMax

      public Integer getMax()
    • setMax

      public void setMax(Integer arg0)
    • getStep

      public Integer getStep()
    • setStep

      public void setStep(Integer arg0)
    • bindMin

      public com.vaadin.flow.dom.SignalBinding<Integer> bindMin(com.vaadin.flow.signals.Signal<Integer> arg0)
    • bindMax

      public com.vaadin.flow.dom.SignalBinding<Integer> bindMax(com.vaadin.flow.signals.Signal<Integer> arg0)
    • bindStep

      public com.vaadin.flow.dom.SignalBinding<Integer> bindStep(com.vaadin.flow.signals.Signal<Integer> arg0)
    • setValueAlwaysVisible

      public void setValueAlwaysVisible(boolean arg0)
    • isValueAlwaysVisible

      public boolean isValueAlwaysVisible()
    • setMinMaxVisible

      public void setMinMaxVisible(boolean arg0)
    • isMinMaxVisible

      public boolean isMinMaxVisible()
    • getValueChangeMode

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

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

      public void setValueChangeTimeout(int arg0)
      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 arg0)
      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>