• 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

How to ignore more than one ActionEvents

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JButton has an ActionListener registered to it.

When handling low-level MouseEvents one can intercept double-clicks and prevent them from doing anything. But how can one do the same thing with higher-level ActionEvents? Multiple ActionEvents are generated with multiple clicks.

In case the answer is to take care of this by writing your own MouseEvent handlers to consume double-clicks, does one have to handle multiple-clicks in all methods of MouseListener?

Thanks
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you store the time, when your action listener code executes (by a call to System.currentTimeInMillis()). Each execution you check that the time is at least, say 500 milliseconds later than the last execution, and if not ignore the event.

D.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic