Results 1 to 4 of 4
- 01-05-2009, 07:20 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 8
- Rep Power
- 0
How to detect double click with a JFrame
Hello everyone,
I was able to find a solution to my problem but I have one issue: my current code thinks the first click of a double click is a normal click. I do not know how to solve this.
The else bracket gets executed when the user is making a double click, on the first click, and it should not. Does anyone has any idea how I can fix this please?Java Code:@Override public void mousePressed(MouseEvent e) { if (!doubleClicked) { if (e.getClickCount() == 2) { .... } else { ... } } }
Thank you very much.
- 01-05-2009, 07:43 PM #2
cross posted !!!
Cross posted at Sun's forums:
New To Java - How to detect double click with a JFrame
You're not supposed to do that... it irritates people and is a good way to not get help.
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 01-05-2009, 08:16 PM #3
You have the right idea, checking the click count. If the click count is not two, don't do anything. One way to handle this is to check for that condition first in your handler. If the click count is not two, return.
- 01-05-2009, 08:39 PM #4
Member
- Join Date
- Dec 2008
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Executing a jar double-click style in Linux
By goodwillwins in forum AWT / SwingReplies: 24Last Post: 03-19-2011, 04:56 AM -
Double click radio button
By mandragora in forum AWT / SwingReplies: 11Last Post: 11-10-2008, 11:06 AM -
Detect when the user scrolls a text control
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:21 PM -
Detect loading of ImageIcon from URL?
By barkster in forum Java AppletsReplies: 1Last Post: 01-29-2008, 07:04 PM -
Detect TimeOut in a HttpURL Connection
By Ed in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 04:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks