Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8170734

Slider#valueChangingProperty remains true when thumb is on the extrem values and mouse is released ouside the Slider

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      The JavaFX slider does not trigger a "value changed + value not changing" when thumb is on the min or max value and the mouse is released outside the bounds of the slider (far left or far right).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Create a Scene with a Slider in it (min = 0; max = 100; default = 50)

      2) Add this snippet to your code

          Slider aSlider = {...}; // some slider in the scene

          aSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
            if(!aSlider.isValueChanging()) {
              // Value is no longer changing
              final String msg = String.format("Slider commit: old<%s> new<%s>", oldValue, newValue);
              System.out.println(msg);
            }
          });

      3) MousePress on the Slider thumb (left button)

      4) Move the mouse to max value (let's say to the right) and continue until the mouse is really outside the bounds of the slider

      5) Release the mouse button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      On the console, we should have the following output: "Slider commit: old<50.0> new<100.0>"
      ACTUAL -
      nothing is displayed on the console!

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Using RXJava and RxJavaFX, I do the following:
      -------------------------------------------------------------

      // Output on the console whenever the slider changes and its value is not adjusting
      final Observable<Number> sliderStream = JavaFxObservable.fromObservableValue(slider.valueProperty());
      final Observable<Boolean> sliderIsChanging = JavaFxObservable.fromObservableValue(slider.valueChangingProperty());

      Observable.combineLatest(sliderStream, sliderIsChanging, (number, isChanging) -> isChanging ? null : number)
              .filter(Objects::nonNull)
              .subscribe(value -> System.out.println("Slider commit: " + value))

            aghaisas Ajit Ghaisas
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: