title: Java : ignore single click on double click?
body: <p>can anyone think of a good way to ignore the single click that comes with a double-click in Java ? </p>
  
  <p>I'm looking to have different behaviors for each such that:</p>
  
  <ul>
  <li>single-click paints crosshairs on the click point</li>
  <li>double-click selects an object on the screen, but should <strong>not</strong> paint crosshairs on the click point</li>
  </ul>
  
  <p>... can anyone think of a way to do this ? Some sort of timer set-up maybe ? An ideas appreciated :-)</p>
  
  <p>&lt;disclaimer> ...and yes, I know I'm committing a most heinous usability / UI faux pas. &lt;/disclaimer></p>
  
  <p><strong>EDIT #2:</strong> </p>
  
  <p>Even though this works the delay due to the timer is maddening - I'm abandoning this solution, and using middle-click for selection instead of double-click...</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thanks <a href="https://stackoverflow.com/users/23325/cgull">cgull</a> - this is what I was able to come up with given your confirmation that there's no easy way to do this (note that if I set the timer &lt; 200 odd racing is seen between the click &amp; the timer, but as long as I set this to a value > 200 things work just peachy) :</p>
  
  <pre><code>public void mouseClicked(MouseEvent e) {
      System.out.println( "Click at (" + e.getX() + ":" + e.getY() + ")" );
      if (e.getClickCount() == 2) {  
          System.out.println( "  and it's a double click!");
          wasDoubleClick = true;
      }else{
          Integer timerinterval = (Integer) 
            Toolkit.getDefaultToolkit().getDesktopProperty(
                        "awt.multiClickInterval");
          timer = new Timer(timerinterval.intValue(), new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  if (wasDoubleClick) {
                      wasDoubleClick = false; // reset flag
                  } else {
                      System.out.println( "  and it's a simple click!");
                  }
              }    
          });
          timer.setRepeats(false);
          timer.start();
      }
  }
  </code></pre>