javaswingmouseeventdouble-click

identifying double click in java


I want to know how can we perform action when mouse is double clicked in a component.


Solution

  • public void mouseClicked(MouseEvent event)
    {
      if (event.getClickCount() == 2 && event.getButton() == MouseEvent.BUTTON1) {
        System.out.println("double clicked");
      }
    }