Double Click Detector
A specialized mouse listener that detects and acts on double-clicks. Simply add it as a MouseListener to any component and add code to do the double-click work. It will react to a double click count even when the second click is not on the exact same pixel as the first click. It plays well with other mouse listeners, ignoring "consumed" mouse events and only consuming events when it actually does something. DoubleClickDetector is best used in a Swing or Awt environment as opposed to Graphics2D. Graphics, if at all interactive, usually requires an elaborate MouseListener implementation with plenty of instance fields and lots of code for each event type. But even with graphics, this code can serve as a proper example of how to handle a double-click.