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