Skip to content
Advertisement

JavaFX Spinner keeps going after removed from scene

I appeared to have discovered a problem with JavaFX Spinner in JavaFX JDK Linux 1.8.0_144. If you are pressing on the increment or decrement button whilst a spinner is removed from the scene the spinner keeps going.

Output

JavaScript

Code

JavaScript

Analysis

In com.sun.javafx.scene.control.skin.SpinnerSkin<T> com.sun.javafx.scene.control.behavior.SpinnerBehavior.stopSpinning() is only ever called on MOUSE_RELEASED event. It appears when spinner is removed from the scene this event is never triggered and no other code exists to stop the spinning.

The fact the spinner is removed is because this example is actually from a larger dynamic application where screens can update automatically from external triggers.

Question

Is this a known bug or something I’m doing wrong? How can I avoid it?

Advertisement

Answer

This remains an unresolved bug (I’ve tested as far as JavaFX 14.0.1). I’ve reported as JDK-8252863

I’ve developed the following workaround which simulates a mouse release in case Scene changes to null.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement