Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help on mouse motion listening

 
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
Marshal
Posts: 52664
122
  • 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: 2703
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Application Inactivity shows how this can be done.
 
Evil is afoot. But this tiny ad is just an ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!