title: Java : detect triple-click without firing double-click
body: <p>I have a JTable in which I want to call a function when a cell is double-clicked and call another function when the cell is triple-clicked.</p>
  
  <p>When the cell is triple-clicked I do not want to call the double-click-function.</p>
  
  <p>What I have right now is (mgrdAlarm is the JTable) :</p>
  
  <pre><code>mgrdAlarm.addMouseListener(new MouseAdapter()
  {
    public void mouseClicked(MouseEvent e)
    {
      System.out.println("getClickCount() = " + e.getClickCount());
      if (e.getClickCount()==2)
      {
        doubleClick();
        System.out.println("Completed : doubleClick()");
      }
      if (e.getClickCount()==3)
      {
        tripleClick();
        System.out.println("Completed : tripleClick()");
      }
    }
  });
  </code></pre>
  
  <p>When double-clicked the console shows :</p>
  
  <pre><code>getClickCount() = 1
  getClickCount() = 2
  Completed : doubleClick()
  </code></pre>
  
  <p>When triple-clicked the console shows :</p>
  
  <pre><code>getClickCount() = 1
  getClickCount() = 2
  Completed : doubleClick()
  getClickCount() = 3
  Completed : tripleClick()
  </code></pre>
  
  <p>When triple-clicked I want the console to show :</p>
  
  <pre><code>getClickCount() = 1
  getClickCount() = 2
  getClickCount() = 3
  Completed : tripleClick()
  </code></pre>
  
  <p>So I do not want to call the function doubleClick() when the cell is triple-clicked, but I do want to call the function doubleClick() when the cell is double-clicked.</p>
  
  <p>[EDIT]</p>
  
  <p>As all replies suggest the solution seems to be to delay the double-click-action and wait a certain time for the triple-click.</p>
  
  <p>But as discussed <a href="https://stackoverflow.com/a/1068302/1584106">here</a> that might lead to a different type of problem :
  The user might have set his double-click-time quite long, which might overlap with the timeout of my triple-click.</p>
  
  <p>It is no real disaster if my double-click-action is executed before my triple-click-action, but it does generate some extra overhead, and especially some extra data traffic which I would like to prevent.</p>
  
  <p>As the only solution so far might lead to other problems, which might actually be worse than the original problem, I will leave it as it is right now.</p>