JDK-4908395 : RFE: Add Toolkit method for getting system 'double-click' speed
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2,6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux,windows_2000
  • CPU: x86
  • Submitted: 2003-08-18
  • Updated: 2008-02-27
Related Reports
Duplicate :  
Description
Name: jk109818			Date: 08/18/2003


A DESCRIPTION OF THE REQUEST :
Many, many bugs reported against a lack of support with single and double click mouse events. Much confusion as well. The user perspective is that the documentation is misleading as it does not distinguish between single and double clicks. This is based on user expectations that single and double clicks are mutually exclusive.

The Sun developer perspective is more of a defensive 'we're following the letter of the law of our documentation'. In other words, we delivered what the documentation says it does. End of story.

Since the user wants one thing and the Java platform offers something different, users are forced to do the following:

panel.addMouseListener(new MouseAdapter() {
  public void mouseClicked(MouseEvent e) {
    long clickTime = System.currentTimeMillis();
    long clickInterval = clickTime-firstClickTime;

    if (clickInterval < 300) {
    // double click
      firstClickTime = 0;
    }
    else {
      firstClickTime = clickTime;
    }
  }
});

While this solves the problem, it is clumbsy, prone to hardcoding and does not allow the user to utilize the underlying platforms double-click property. One can only guess the magic number for that double-click speed.



JUSTIFICATION :
I propose a compromise. I would like to see a method found within the java.awt.Toolkit that allows for the property of double-click speed to be retrieved as a long:

public long getSystemDoubleClickSpeed()

This and along with a reference to this in the documentation (specifically in the MouseEvent getClickCount() method that says:

see java.awt.Toolkit.getSystemDoubleClickSpeed()

As well as a little more than the current 1 liner in getClickCount() which only states "Returns the number of mouse clicks associated with this event." The replacement description should work towards eliminating the confusion, thus descreasing fustration on both sides and virtually eliminating any bug reports that have to do with double clicks.


---------- BEGIN SOURCE ----------
panel.addMouseListener(new MouseAdapter() {
  public void mouseClicked(MouseEvent e) {
    long clickTime = System.currentTimeMillis();

    // this is the replacement ... notice the system property
    long clickInterval = java.awt.Toolkit.getSystemDoubleClickSpeed();

    if (clickInterval < 300) {
    // double click
      firstClickTime = 0;
    }
    else {
      firstClickTime = clickTime;
    }
  }
});
---------- END SOURCE ----------
(Incident Review ID: 199324) 
======================================================================

Comments
EVALUATION I think we already provide this information through a desktop property. ###@###.### 2003-08-19 It is "awt.multiClickInterval". ###@###.### 2005-1-11 09:31:39 GMT
19-08-2003