• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help on mouse motion listening

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Application Inactivity shows how this can be done.
reply
    Bookmark Topic Watch Topic
  • New Topic