1. Domino UI
  2. Components
  3. Sliders
Top Basic Colored Picker Docs

Sliders

Represents a UI slider component.

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 :

Examples

Basic sliders Simple sliders, min/max and thumb.

Colored sliders Sliders can have different colors.

Color picker example A sample to show slider in action.

API Docs: Slider

Constructors

public void Slider(double max, double min, double value)
Main constructor to create a Slider.

max

the maximum value

min

the minimum value

value

the initial value

Static methods

public static Slider create(double max)
Creates a slider with a specified maximum value.

max

the maximum value for the slider



Returns:

a new slider instance

public static Slider create(double max, double min)
Creates a slider with a specified maximum and minimum value.

max

the maximum value for the slider

min

the minimum value for the slider



Returns:

a new slider instance

public static Slider create(double max, double min, double value)
Creates a slider with specified maximum, minimum, and initial value.

max

the maximum value for the slider

min

the minimum value for the slider

value

the initial value for the slider



Returns:

a new slider instance

Public methods

public Slider pauseChangeListeners()
Pauses the change listeners so they won't get triggered on value changes.

Returns:

the current slider instance

public Slider resumeChangeListeners()
Resumes the change listeners so they get triggered on value changes.

Returns:

the current slider instance

public Slider togglePauseChangeListeners(boolean toggle)
Toggles the pause state of the change listeners.

toggle

if true, pause the listeners, otherwise resume them



Returns:

the current slider instance

public Set<ChangeListener<? super Double>> getChangeListeners()
Gets the set of change listeners attached to the slider.

Returns:

the set of change listeners

public boolean isChangeListenersPaused()
Checks if the change listeners are currently paused.

Returns:

true if listeners are paused, false otherwise

public Slider triggerChangeListeners(Double oldValue, Double newValue)
Triggers the change listeners manually with given old and new values.

oldValue

the previous value

newValue

the current value



Returns:

the current slider instance

public Slider withThumb(ChildHandler<Slider, SpanElement> handler)
Configures the slider to show its thumb and applies additional customizations using the provided handler.

handler

a handler that allows customizations of the slider's thumb



Returns:

the current slider instance

public Slider withThumb()
Configures the slider to show its thumb without any additional customizations.

Returns:

the current slider instance

public Slider setMaxValue(double max)
Sets the maximum value of the slider.

max

the maximum value to be set



Returns:

the current slider instance

public Slider setMinValue(double min)
Sets the minimum value of the slider.

min

the minimum value to be set



Returns:

the current slider instance

public Slider setValue(double newValue, boolean silent)
Sets the value of the slider and optionally triggers change listeners.

newValue

the new value to be set

silent

if true, change listeners won't be triggered



Returns:

the current slider instance

public Slider setValue(double newValue)
Sets the value of the slider and triggers change listeners.

newValue

the new value to be set



Returns:

the current slider instance

public Slider setStep(double step)
Sets the stepping value of the slider.

step

the stepping value to be set



Returns:

the current slider instance

public Slider anyStep()
Configures the slider to accept any step value.

Returns:

the current slider instance

public double getMax()
Gets the maximum value of the slider.

Returns:

the maximum value

public double getMin()
Gets the minimum value of the slider.

Returns:

the minimum value

public double getValue()
Gets the current value of the slider.

Returns:

the current value

public Slider setShowThumb(boolean withThumb)
Sets whether the slider should show its thumb.

withThumb

if true, the thumb will be shown



Returns:

the current slider instance

public Slider setDirection(SliderDirection direction)
Sets the orientation of this slider to the specified direction.

direction

the SliderDirection to apply; if null , no change will be applied



Returns:

this Slider instance for method chaining

public Slider vertical()
Configures this slider to be displayed vertically.

Returns:

this Slider instance for method chaining

public Slider horizontal()
Configures this slider to be displayed horizontally.

Returns:

this Slider instance for method chaining

public HTMLDivElement element()
Returns the root HTML div element of the slider.

Returns:

the root HTML div element

public Slider addChangeListener(ChangeListener<? super Double> changeListener)
Adds a change listener to the slider. This listener will be notified of value changes.

changeListener

the listener to be added



Returns:

the current slider instance

public Slider removeChangeListener(ChangeListener<? super Double> changeListener)
Removes a specific change listener from the slider.

changeListener

the listener to be removed



Returns:

the current slider instance

public boolean hasChangeListener(ChangeListener<? super Double> changeListener)
Checks if the slider has the specified change listener.

changeListener

the listener to check for



Returns:

true if the listener is present, false otherwise

public Slider setThumbStyle(ThumbStyle thumbStyle)
Changes the thumb style for this slider

thumbStyle

ThumbStyle



Returns:

same slider instance

We are a group of passionate people who love what we do

Donate & Support Us