The slider allows users to select a value from a range by moving the slider thumb.
Usage example:
Slider slider = Slider.create(100, 0, 50); // max: 100, min: 0, initial value: 50
slider.addChangeListener(value -> {
System.out.println("New value: " + value);
});
See also :
public void Slider(double max, double min, double value)
max
the maximum value
min
the minimum value
value
the initial value
public static Slider create(double max)
max
the maximum value for the slider
a new slider instance
public static Slider create(double max, double min)
max
the maximum value for the slider
min
the minimum value for the slider
a new slider instance
public static Slider create(double max, double min, double value)
max
the maximum value for the slider
min
the minimum value for the slider
value
the initial value for the slider
a new slider instance
public Slider pauseChangeListeners()
the current slider instance
public Slider resumeChangeListeners()
the current slider instance
public Slider togglePauseChangeListeners(boolean toggle)
toggle
if true, pause the listeners, otherwise resume them
the current slider instance
public Set<ChangeListener<? super Double>> getChangeListeners()
the set of change listeners
public boolean isChangeListenersPaused()
true if listeners are paused, false otherwise
public Slider triggerChangeListeners(Double oldValue, Double newValue)
oldValue
the previous value
newValue
the current value
the current slider instance
public Slider withThumb(ChildHandler<Slider, SpanElement> handler)
handler
a handler that allows customizations of the slider's thumb
the current slider instance
public Slider withThumb()
the current slider instance
public Slider setMaxValue(double max)
max
the maximum value to be set
the current slider instance
public Slider setMinValue(double min)
min
the minimum value to be set
the current slider instance
public Slider setValue(double newValue, boolean silent)
newValue
the new value to be set
silent
if true, change listeners won't be triggered
the current slider instance
public Slider setValue(double newValue)
newValue
the new value to be set
the current slider instance
public Slider setStep(double step)
step
the stepping value to be set
the current slider instance
public Slider anyStep()
the current slider instance
public double getMax()
the maximum value
public double getMin()
the minimum value
public double getValue()
the current value
public Slider setShowThumb(boolean withThumb)
withThumb
if true, the thumb will be shown
the current slider instance
public Slider setDirection(SliderDirection direction)
direction
the SliderDirection to apply; if null , no change will be applied
this Slider instance for method chaining
public Slider vertical()
this Slider instance for method chaining
public Slider horizontal()
this Slider instance for method chaining
public HTMLDivElement element()
the root HTML div element
public Slider addChangeListener(ChangeListener<? super Double> changeListener)
changeListener
the listener to be added
the current slider instance
public Slider removeChangeListener(ChangeListener<? super Double> changeListener)
changeListener
the listener to be removed
the current slider instance
public boolean hasChangeListener(ChangeListener<? super Double> changeListener)
changeListener
the listener to check for
true if the listener is present, false otherwise
public Slider setThumbStyle(ThumbStyle thumbStyle)