Idle time in swing application

Hi All,

How to get idle time for swing application.My swing applicatioon having few forms, all forms having database operation.Lets assume,

1 hour long user not did any operation, but application is running just idle.I want to close the entire application(exit ) when 1 hour long application is idle(Like session expired in web).How to do that.

Thanks in advance.

[389 byte] By [Ramsha] at [2007-10-3 8:26:16]
# 1

If it is idle does that hurt anything?

You don't have database connections open do you? If so just close those and I would wait for less time than an hour of inactivity to close those.

Anyway, just track activity and have a timer that polls every so often and when there has not be activity for the specified time just call: System.exit(0);

zadoka at 2007-7-15 3:32:38 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks for your Quick reply, How to get, if any action is performed,(it may be mouse action or key action).
Ramsha at 2007-7-15 3:32:38 > top of Java-index,Desktop,Core GUI APIs...
# 3
> Thanks for your Quick reply,> How to get, if any action is performed,(it may be> mouse action or key action).Use a mouseListener and KeyListener. Or just track events in your application (If they click they probably are clicking on a button or something).
zadoka at 2007-7-15 3:32:38 > top of Java-index,Desktop,Core GUI APIs...
# 4
Thanks a lot for given some idea
Ramsha at 2007-7-15 3:32:38 > top of Java-index,Desktop,Core GUI APIs...
# 5

Use an AWTEventListener to listen for events and reset the time every time an event is generated.

Toolkit.getDefaultToolkit().addAWTEventListener( new AWTEventListener()

{

public void eventDispatched(AWTEvent e)

{

System.out.println(e);

}

}, AWTEvent.MOUSE_MOTION_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK);

//}, AWTEvent.KEY_EVENT_MASK);

camickra at 2007-7-15 3:32:38 > top of Java-index,Desktop,Core GUI APIs...
# 6
Thanks a lot for help, This is exactly what i need.
Ramsha at 2007-7-15 3:32:38 > top of Java-index,Desktop,Core GUI APIs...