How do I detect mouse double clicks?

Jon Wingfield

You do this by adding a MouseListener or MouseAdapter to the component which the user will double-click. The MouseEvent fired will contain the number of clicks:

comp.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
        // check for double-clicks
        if (e.getClickCount() == 2) {
            // do something here
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.