By default MouseClicked event starts with one click. I have one in a JTextPane but I want to start with double click. Is it possible?
-
"Mouseclicked event starts with one click" makes no sense: mouseClicked events are dispatched whenever matching pressed/released are detected, for any number of clicks. What exactly are you trying to do?kleopatra– kleopatra2011-12-07 09:07:26 +00:00Commented Dec 7, 2011 at 9:07
-
yeah, I understand that, technically, but what's the problem? simply use @Johnny Rocket 's answer ...kleopatra– kleopatra2011-12-07 10:08:24 +00:00Commented Dec 7, 2011 at 10:08
Add a comment
|
5 Answers
I believe you can extract the click count from the MouseEvent (assuming its called e)
Try this
if (e.getClickCount() == 2 && !e.isConsumed()) {
e.consume();
//handle double click event.
}
I don't think there will be a solution to this, since Java can run on non-pc devices.
Most portable devices don't support double-click.
You may keep track of the moment of each mouse click and fire your own "double-click" event. But I don't think this is a good idea.
1 Comment
kleopatra
hmm .. where do you see mobile devices come into play?