> So how to distinguish mouse single click and mouse double click? Thanks a
lot!
You should just be able to check the value of 'count' and only execute your
double click code when there have been 2 mouse clicks.
You might also check which mouse button the clicks came from.

tableView.getComponentMouseButtonListeners().add(new
ComponentMouseButtonListener() {

@Override
public boolean mouseClick(Component component, Button button, int x, int y,
int count) {
  if (count == 1) {
  // Single click
   return true;
 } else if (count == 2) {
  // Double click
   return true;
}
System.out.println(count);
return false;
 }
 });



On 5 May 2011 14:08, Le Zhou <[email protected]> wrote:

> Hi all,
>
> I added one ComponentMouseButtonListener instance to one TableView
> instance, and overrided the mouseClick method
> of ComponentMouseButtonListener class.
> When i performed  one double click on the TableView, the mouseClick method
> was called twice. Below are snippet of the experiment code:
>
> tableView.getComponentMouseButtonListeners().add(new
> ComponentMouseButtonListener() {
>
> @Override
> public boolean mouseClick(Component component, Button button, int x, int y,
> int count) {
>  System.out.println(count);
> return false;
> }
>  });
>
> When i performed one double click on the tableView, output is like below:
>
> 1
> 2
>
> I was kinda confused, because i thought the output should be "2".
> I thought the count argument in mouseClick method is used to distinguish
> mouse single click and mouse double click events.
> But as shown in the output, it seems that the mouseClick method is called
> twice in one mouse double click event: count is 1 in the 1st call and count
> is 2 in the 2nd call.
>
> So how to distinguish mouse single click and mouse double click? Thanks a
> lot!
>
>
>

Reply via email to