> if ( e.getClickCount() > 1 )

No, that's worse.  Now it responds to single clicks until all previous
clicks expire.  The problem is that the clickcount can easily rise to 3, 4,
or 5, which is useless for distinguishing double from single clicks.

Here's the best solution I found:
if (  (e.getClickCount() % 2) == 0  )

In other words, response whenever the clickcount is even, but not if it's
odd.  Works pretty well (but not perfect).

James

>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of James Brundege
> Sent: Thursday, April 04, 2002 4:09 PM
> To: [EMAIL PROTECTED]
> Subject: MouseEvent ClickCount
>
>
> Hey all,
> This should be simple, but I'm baffled.  I have a component that responds
to
> a double click.  I detected the double-click with a mouse adapter:
>             public void mouseClicked(MouseEvent e) {
>                 if ( e.getClickCount() == 2 ) {
>
> The problem is that the duration over which the mouse clicks are held
seems
> long to me.  If a user double-clicks twice in succesion, the 2nd one is
> ignored because the clickCount is now 3 or 4.  On the other hand, if they
> wait one second and then click once, it responses because the clickcount
> fell to one, then rose back to 2.
>
> The easy solution would be to reset the clickCount to 0 after a
double-click
> is registered.  However, I can see no way to do this.  Does anyone have a
> solution to this (certainly common) problem?
>
> Thanks,
> James Brundege
>
>
>
>
>
>
>

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to