Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4908395

RFE: Add Toolkit method for getting system 'double-click' speed

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 1.4.2, 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux, windows_2000

      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dav Andrei Dmitriev (Inactive)
              Reporter:
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: