1

A change listener can be added to Slider like this.

slider.valueProperty().addListener(new ChangeListener<Number>() {
    public void changed(ObservableValue<? extends Number> o,
       Number old, Number newValue) {
    }
});

I only want to receive events after the user has finished sliding, i.e. released the mouse, or finger etc. I've tried using the isValueChanging() method but this always returns true when changing the value with the mouse.

Swing's original JSlider had a isValueAdjusting() which worked by returning true, and then false once the value was set. Is there anyway of achieving the same effect with JavaFX?

Adam
  • 35,919
  • 9
  • 100
  • 137
  • The suggested duplicate is not very clear or complete. To clarify, the solution is to use two listeners. Listener 1 on valueChangingProperty() which grabs the value when it valueChanging turns to false - this handles mouse / touch updates. Listener 2 on valueProperty() which grabs the value when valueChanging is false - handles the case where the slider is moved using the keyboard cursor keys. – Adam Aug 14 '14 at 11:54

0 Answers0