Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Detecting double click with MouseListener

Reply
Thread Tools

Detecting double click with MouseListener

 
 
John
Guest
Posts: n/a
 
      08-31-2004
Jacob wrote:

> I can detect a docuble click using the MouseListener
> interface and inspect the event.getClickCount().
>
> However, at that point in time, the event has already
> been classified as a single click (as the clickCount
> is 1 the first time around).
>
> My intention is to start action A on a single click
> and action B on a double click. With a standard setup
> I will get action A on a single click but action A + B
> on a double click!
>
> Seems like a delay is necessary in order to fully
> classify the event. Is there a standard way to acheive
> this?
>
> Thanks.
>


Let's say the double click listener calls the method
handleDoubleClick(). In the single click listener, check the number of
clicks, and if it is 2, call handleDoubleClick().

Do NOT start buggering about with delays and things or your UI code will
degenerate into rubbish.

John
 
Reply With Quote
 
 
 
 
Jacob
Guest
Posts: n/a
 
      08-31-2004
I can detect a docuble click using the MouseListener
interface and inspect the event.getClickCount().

However, at that point in time, the event has already
been classified as a single click (as the clickCount
is 1 the first time around).

My intention is to start action A on a single click
and action B on a double click. With a standard setup
I will get action A on a single click but action A + B
on a double click!

Seems like a delay is necessary in order to fully
classify the event. Is there a standard way to acheive
this?

Thanks.

 
Reply With Quote
 
 
 
 
staff
Guest
Posts: n/a
 
      08-31-2004
John wrote:

> Jacob wrote:
>
>> I can detect a docuble click using the MouseListener
>> interface and inspect the event.getClickCount().
>>
>> However, at that point in time, the event has already
>> been classified as a single click (as the clickCount
>> is 1 the first time around).
>>
>> My intention is to start action A on a single click
>> and action B on a double click. With a standard setup
>> I will get action A on a single click but action A + B
>> on a double click!
>>
>> Seems like a delay is necessary in order to fully
>> classify the event. Is there a standard way to acheive
>> this?
>>
>> Thanks.
>>

>
> Let's say the double click listener calls the method
> handleDoubleClick(). In the single click listener, check the number of
> clicks, and if it is 2, call handleDoubleClick().


This is not a solution. When double clicking two events are generated. First
with clickCount = 1, second with cilckCount = 2.

Greetings
Pawel Stawicki
 
Reply With Quote
 
Niels Dybdahl
Guest
Posts: n/a
 
      08-31-2004
> Let's say the double click listener calls the method
> handleDoubleClick(). In the single click listener, check the number of
> clicks, and if it is 2, call handleDoubleClick().
>
> Do NOT start buggering about with delays and things or your UI code will
> degenerate into rubbish.


The Java versions I have worked with (Sun), there is only one
mouseclickevent, and in the case of a double click, that event is fired
twice, once with a clickcount of 1 and once with a clickcount of 2. At the
time when the clickcount of 1 is present, there is no way to determine
whether the user will click once more.

One possible method is to select a singleclickaction which does not conflict
with the doubleclickaction. F.ex single click->selection, double
click->activation.

I have had a few cases where I wanted actions that did conflict. I did not
implement the delay, but changed the actions.

Niels Dybdahl


 
Reply With Quote
 
John
Guest
Posts: n/a
 
      08-31-2004
staff wrote:

> John wrote:
>
>
>>Jacob wrote:
>>
>>
>>>I can detect a docuble click using the MouseListener
>>>interface and inspect the event.getClickCount().
>>>
>>>However, at that point in time, the event has already
>>>been classified as a single click (as the clickCount
>>>is 1 the first time around).
>>>
>>>My intention is to start action A on a single click
>>>and action B on a double click. With a standard setup
>>>I will get action A on a single click but action A + B
>>>on a double click!
>>>
>>>Seems like a delay is necessary in order to fully
>>>classify the event. Is there a standard way to acheive
>>>this?
>>>
>>>Thanks.
>>>

>>
>>Let's say the double click listener calls the method
>>handleDoubleClick(). In the single click listener, check the number of
>>clicks, and if it is 2, call handleDoubleClick().

>
>
> This is not a solution. When double clicking two events are generated. First
> with clickCount = 1, second with cilckCount = 2.
>
> Greetings
> Pawel Stawicki


Ok, apologies. (and to OP).

John
 
Reply With Quote
 
Jacob
Guest
Posts: n/a
 
      09-01-2004
Jacob wrote:


> I can detect a docuble click using the MouseListener
> interface and inspect the event.getClickCount().
>
> However, at that point in time, the event has already
> been classified as a single click (as the clickCount
> is 1 the first time around).
>
> My intention is to start action A on a single click
> and action B on a double click. With a standard setup
> I will get action A on a single click but action A + B
> on a double click!
>
> Seems like a delay is necessary in order to fully
> classify the event. Is there a standard way to acheive
> this?



I'll try to fix this myself; In doing so I need access
to the system click interval. How?

Thanks!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
Newbie MouseListener Problem Cammy Java 2 04-10-2004 06:34 PM
Weird Problem in using MouseListener Minti Java 2 02-19-2004 07:23 PM
MouseListener and hiding components. Peter the Swede Java 0 11-19-2003 10:57 AM
Invoking an action from a MouseListener on a JTable Brian J. Sayatovic Java 1 07-31-2003 04:40 PM



Advertisments