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

ClickCount from MouseEvent does not consistently show multiple clicks

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux ims-360-9-lnx 2.4.21-4.0.1.ELsmp #1 SMP Thu Oct 23 01:27:36 EDT 2003 i686 i686 i386 GNU/Linux

      SunOS topaz 5.8 Generic_108528-23 sun4u sparc SUNW,Ultra-5_10 (using JDK 1.4.2)

      A DESCRIPTION OF THE PROBLEM :
      My users have occassionally noticed that when they are double-clicking items in our application that the tool is not responding. My response to them has been; they either moved their mouse between clicks or need to click faster. Now I'm getting a flood of complaints, so I thought I'd look into the problem some more.

      I've found that double-clicking in our GUI does not always bring back a value greater than 1. In some cases multiple (more than two) clicks at the same location will return a MouseEvent with a clickCount of one (1). Once a double-click is recognized for a location, multiple clicks are processed correctly for the clickCount.

      This isn't consistent but I've found it easily reproducible using the ListDemo program
      from the Swing tutorial. This problem can be seen in JDK 1.4.2 (Linux/Solaris) and JDK 1.5.0 (Linux)/Solaris

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the program below.

      Start double-clicking on the names in the JList. There is output to the terminal showing the positiion of the mouse and the click count. In most cases, you will see the first clickCount correctly return a "1", followed the second clickCount returning a "2"; but occassionally you will see the second click reporting "1".


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      See above.
      ACTUAL -
      See above.

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;
       
      public class ListDemo extends JFrame
                            implements MouseInputListener {
          private JList list;
          private DefaultListModel listModel;
       
          private JTextField employeeName;
       
          public ListDemo() {
              super("ListDemo");
       
              listModel = new DefaultListModel();
              listModel.addElement("Alison Huml");
              listModel.addElement("Kathy Walrath");
              listModel.addElement("Lisa Friendly");
              listModel.addElement("Mary Campione");
       
              //Create the list and put it in a scroll pane
              list = new JList(listModel);
              list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              list.setSelectedIndex(0);
              list.addMouseListener(this);
      // list.addMouseMotionListener(this);
              JScrollPane listScrollPane = new JScrollPane(list);
       
              employeeName = new JTextField(10);
              String name = listModel.getElementAt(
                                    list.getSelectedIndex()).toString();
              employeeName.setText(name);
       
              JPanel buttonPane = new JPanel();
              buttonPane.add(employeeName);
       
              Container contentPane = getContentPane();
              contentPane.add(listScrollPane, BorderLayout.CENTER);
              contentPane.add(buttonPane, BorderLayout.SOUTH);
          }
       
          // Implement MouseListener
          public void mouseClicked(MouseEvent e) {
              System.out.println("mouseClicked: " + e.getPoint() +
                                       ", clickCount = " + e.getClickCount());
          }
       
          public void mousePressed(MouseEvent e) { }
          public void mouseEntered(MouseEvent e) { }
          public void mouseExited(MouseEvent e) { }
          public void mouseReleased(MouseEvent e) { }
          public void mouseMoved(MouseEvent e) {
              System.out.println("mouseMoved");
          }
          public void mouseDragged(MouseEvent e) {
              System.out.println("mouseDragged");
          }
       
          public static void main(String s[]) {
              JFrame frame = new ListDemo();
       
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });
       
              frame.pack();
              frame.setVisible(true);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      You could put something in the mouseClicked() method that checks the last
      last time you clicked the mouse to determine the double-click rather than
      using the clickCount() method.
      ###@###.### 10/28/04 18:30 GMT

        Attachments

          Activity

            People

            Assignee:
            dav Andrei Dmitriev (Inactive)
            Reporter:
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: