File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes trapping double clicks using getClickCount of MouseEvent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "trapping double clicks using getClickCount of MouseEvent" Watch "trapping double clicks using getClickCount of MouseEvent" New topic
Author

trapping double clicks using getClickCount of MouseEvent

Frank Hale
Ranch Hand

Joined: Mar 25, 2000
Posts: 230
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

Joined: Jun 27, 2000
Posts: 286
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trapping double clicks using getClickCount of MouseEvent