Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trapping double clicks using getClickCount of MouseEvent

 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to know if there is a better way to trap double clicks then using getClickCount() in MouseEvent?
Using getClickCount is not reliable in my tests. Most of the time when I trap double clicks it is not working 100% of the time. One has to click slowly in order for it to be somewhat reliable.
Has anyone seen this problem?
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
easy to get around. Use a
Date lastClick;
variable. Check lastClick.getTime() in the mouseClicked method (or mousePressed).
If it is within a certain number of milisecs of the current time, its a double click and you kick off your event.
If it is out of the time range you specify it sets the lastClick to the current time and exits waiting for the next click.
Hope this helps,
Chris
[ October 07, 2002: Message edited by: Chris Shepherd ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic