Mouse event with double click in java

后端 未结 5 2123
借酒劲吻你
借酒劲吻你 2020-12-18 19:49

By default MouseClicked event starts with one click. I have one in a JTextPane but I want to start with double click. Is it possible?

5条回答
  •  忘掉有多难
    2020-12-18 20:28

    I believe you can extract the click count from the MouseEvent (assuming its called e)

    Try this

    if (e.getClickCount() == 2 && !e.isConsumed()) {
         e.consume();
         //handle double click event.
    }
    

提交回复
热议问题