The Artima Developer Community
Sponsored Link

Java Answers Forum
user idle time

3 replies on 1 page. Most recent reply: Dec 7, 2002 8:51 AM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Christina

Posts: 2
Nickname: christina3
Registered: Dec, 2002

user idle time Posted: Dec 5, 2002 2:53 PM
Reply to this message Reply
Advertisement
Hello,

Is there a way to tell how long a user has been idle from their computer, whether or not their applet is minimized? Thanks so much for your help!

Christina


Venugopal Bandari

Posts: 5
Nickname: bandari
Registered: Dec, 2002

Re: user idle time Posted: Dec 6, 2002 1:55 AM
Reply to this message Reply
hai,

take a instance variable long (ex: long t1), in Applet init initialize to System.currentMillis(); wait for a event to occur in ur Applet or Application. event may be focus, key, mouse etc.., in event handler get the System.currentMillis(); (ex: t2) and substract this with instance long variable which u initilized in init. then u will get the idle time of first event. i.e., idle time = t2-t1. then assign t1 to t2=> t1 = t2. then wait for next event to occur.

ok..have u got it..

Christina

Posts: 2
Nickname: christina3
Registered: Dec, 2002

Re: user idle time Posted: Dec 6, 2002 6:01 AM
Reply to this message Reply
Thank you for your help. I was actually wanting to make an applet stop working if the user has been idle from their computer for a certain period of time. So if they haven't touched their keyboard or mouse (whether or not they were interacting with the applet or another application the last time they were using their computer).

Thanks :)

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: user idle time Posted: Dec 7, 2002 8:51 AM
Reply to this message Reply
Venugopal's solution has two draw-backs I reckon, is that you need to listen for all the possible events on all the possible elements of you application. I would consider to limit your self in say (window is not the focused window).

This is not the worst (sorry Venugopal :-( nothing personnal). The answer given means you need to wait on the wake up event to know if you can put your application asleep :-((

I think you need to use a background thread to monitor the activity of the system... if you want to be able to put your application asleep while the app has the focus. If it's only when the App is not in focus,then it might be doable without !

Have a nice day,

Thomas SMETS,
SCJP2 - Brussels

Flat View: This topic has 3 replies on 1 page
Topic: Can text be inserted into a file using RandomAccessFile? Previous Topic   Next Topic Topic: Servlets in Iplanet Application Server

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use