I think you already gave yourself the answer:

if (count == 2) {
    System.out.println("Double click!");
}

-- Edvin

Den 05.05.2011 09:08, skrev Le Zhou:
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