• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help on mouse motion listening  RSS feed

 
Leo Leong
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am doing a small website assignment on Java GUI and I decided to implement a function on listening the mouse where if the mouse is not move or click and a few seconds it will logout. I found an example in oracle on mouse motion listener but I'm not sure how to use the codes. Can anyone help and give a little advice?
 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Maybe you should try a timer. The mouse motion listener and the mouse listener (you need both) reset a timeInactive variable to 0. The timer increases the timeInactive variable, and when it reaches the allowable timeout, you can fire the logoff. You wil find out about timers here and here.

Beware: Those two timers are different, and have to be used differently.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Application Inactivity shows how this can be done.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!