I am creating javafx application and i want to put screen saver functionality to my application.
If user become inactive for a period of time ( like 1 min ) and did not do any mouse event , i want to add another pane with image on top of it.
when user generates mouse click, screensaver screen should be removed and previous screen should be visible.
Any one can guide me how to do it ?
I know it can be done by generating a new thread but every time a mouse event occurs , i cant add new thread everytime.
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("/fxmls/Main.fxml"));
Scene scene = new Scene(root,800,480);
scene.addEventFilter(MouseEvent.MOUSE_RELEASED, (EventHandler<MouseEvent>) event -> {
EventTarget comp = event.getTarget();
System.out.println("Event Occured :- " + comp.toString());
});
primaryStage.setScene(scene);
primaryStage.setTitle("Test");
primaryStage.show();
}
this is i have done so far, i put listener to every mouse click occurred on scene.