0

I found the following idle question: JavaFX 2 User Idle Detection however, I would like to create a global idle detection regardless of scene or stage.

Is there a way to check for idle on the FX Application as a whole, so that I can close it?

For example, I have a task window, which launches secondary stages, so if the user is working on one of those stages, I don't want the idle on the task window to fire.

The only examples I have seen are either scene or stage related.

For example:

MainWindow ->opens Window 1

MainWindow ->opens Window 2

MainWindow and Window 1 are idle while user interacts with Window 2 - idle should not fire.

However MainWindow, Window 1 and Window 2 are ALL idle, then it should.

Thanks!

Thanks!

Community
  • 1
  • 1
purring pigeon
  • 4,141
  • 5
  • 35
  • 68
  • Doesn't the solution you linked work? Just call `register(...)` once for each window, passing the scene each time? – James_D Jan 30 '15 at 15:09
  • We will have several dozen windows - each may be active, so Idle on one doesn't mean idle on the application. – purring pigeon Jan 30 '15 at 16:41
  • I mean you use the same `IdleMonitor` instance and register all the scenes with it. Then "not idle" on any scene will reset the (single) timer. – James_D Jan 30 '15 at 16:43
  • I guess my concern here is having to replicate this code, and have developers remember to do it, rather than handle it right at login once for the entire application. – purring pigeon Jan 30 '15 at 16:51
  • There are a number of solutions for that. E.g. write a utility method that creates stages for you, or have a stage subclass. These can observe the scene property and register/unregister it with a (singleton) `IdleMonitor`. I suspect in an application with "several dozen" windows there is other common functionality you need anyway. – James_D Jan 30 '15 at 17:03

0 Answers0