KJW
KJW

Reputation: 15251

how to detect double clicks in MouseInput in Java swing?

How can I catch when user double clicks on the component?

 window.getComponent().addMouseListener(new MouseInputAdapter(){
            public void mouseClicked(final java.awt.event.MouseEvent evt) {
                Xpcom.invokeLater(new Runnable() {
                    public void run() {

                    }
                });                
            }
        })

;

Upvotes: 0

Views: 8645

Answers (2)

Peter Becker
Peter Becker

Reputation: 8855

See the following post:

Distinguish between a single click and a double click in Java

Upvotes: 1

Bala R
Bala R

Reputation: 108957

You'll have to use the getClickCount() of MouseEvent

if (evt.getClickCount() == 2)  // double click
{
    // do stuff
}

Upvotes: 6

Related Questions