开发者

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

                    }
                });                
       开发者_如何学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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜