JavaFX sets up a hidden mouse in standby mode

How can I hide the mouse from a JavaFX application when the user is idle for, say, for 1 second? and show it again when the mouse moves?

I have this piece of code

scene.setCursor(Cursor.NONE);

But I do not know how to relate it to downtime.

0
source share
1 answer

You can do something like this:

PauseTransition idle = new PauseTransition(Duration.seconds(1));
idle.setOnFinished(e -> scene.setCursor(Cursor.NONE));
scene.addEventHandler(Event.ANY, e -> {
    idle.playFromStart();
    scene.setCursor(Cursor.DEFAULT);
});

. - , , . , , (.. ), NONE.

+3

Source: https://habr.com/ru/post/1653462/


All Articles