Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MouseEvent doubleClick Listener

893630Oct 29 2012 — edited Oct 31 2012
Hi,
I have a requirement in which when you click a node you call "action A" and on double click you call "action B".

I was using the following code all this while:

+Node.setOnMouseClicked(new EventHandler<MouseEvent>(){+*
+@Override+
+public void handle(MouseEvent arg0) {+*
+if(arg0.getClickCount()==1){+*
+// do Action A.+
+}+
+if(arg0.getClickCount()==2){+*
+// do Action B.+
+}+
+}+
+});+

However, on double click-- this also triggers first click action . To make the matter worse, if Action A called by first click takes substantial time , then double click is interpreted as two single clicks not a double Click and action B never gets executed.
Is there any Listener to differentiate single and double click?
Pls advice appropriate approach for this.

Thanks
This post has been answered by James_D on Oct 31 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2012
Added on Oct 29 2012
11 comments
3,584 views