开发者

how to detect double clicks in MouseInput in Java swing?

开发者 https://www.devze.com 2023-03-02 10:01 出处:网络
How can I catch when user double clicks on the component? window.getComponent().addMouseListener(new MouseInputAdapter(){

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() {

                    }
                });                
       开发者_如何学JAVA     }
        })

;


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

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


See the following post:

Distinguish between a single click and a double click in Java

0

精彩评论

暂无评论...
验证码 换一张
取 消