JDK-6578074 : MouseListener mouseClicked() no Event fired for 2xClick on tablet PC
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-07-09
  • Updated: 2011-02-16
  • Resolved: 2007-10-22
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Widows XP [Version 5.1.2600]

Laptop - Toshiba Portege M400 - Tablet PC

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tablet PC, problem occurs when working with the stylus on the screen only. When mouse is used problem does not occur.

A DESCRIPTION OF THE PROBLEM :
java.awt.MouseListener mouseClicked( MouseEvent e )
Fires an event for single click but does not fire an event for double click, that is when e.getClickCount() >= 2. So double / triple clicks are not picked up.

This only happens when using the stylus with the Tablet PC, when using the mouse on the same PC the problem does not occur.

This affects usage of standard java components, such as JFileChooser, where the user can not double click on a directory folder to navigate through directories.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a tablet PC (I used toshiba Portege M400) and using the Stylus.
Compile and run the source code included.

Once code is run, there are 2 tests:
Test 1.
Double click on a directory folder in the JFileChooser to navigate to a subdirectory.

Test 2.
Double click inside the JFrame with the style.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Test 1.
Double clicking on a subfolder takes the user to that folder for further navigating on the JFileChooser.

Test 2.
System.out should say:
--- System.out OUTPUT START ---
---- mouseEntered
---- mousePressed
Button 1
Click count: 1
---- mouseReleased
Button 1
Click count: 1
---- mouseClicked
Button 1
Click count: 1
---- mousePressed
Button 1
Click count: 2
---- mouseReleased
Button 1
Click count: 2
---- mouseClicked
Button 1
Click count: 2
---- mouseExited
--- System.out OUTPUT END ---
ACTUAL -
Test 1.
Subfolder is just highlighted and double clicking does not take the user into the subfolder for further navigating on the JFileChooser.

Test 2.
System.out says:
--- System.out OUTPUT START ---
---- mouseEntered
---- mousePressed
Button 1
Click count: 1
---- mouseReleased
Button 1
Click count: 1
---- mouseClicked
Button 1
Click count: 1
---- mousePressed
Button 1
Click count: 2
---- mouseReleased
Button 1
Click count: 2
---- mouseExited
--- System.out OUTPUT END ---

(Note that the ---- mouseClicked event for clickCount: 2 does not appear here)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/** Mouse.java - Test for the MouseListener */

import java.awt.event.*;
import javax.swing.*;

public class Mouse implements MouseListener {
  
  public void mouseClicked(MouseEvent e) {
    System.out.println( "---- mouseClicked" );
    printEvents(e);
  }
  
  public void mouseEntered(MouseEvent e) {
    System.out.println( "---- mouseEntered" );
    printEvents(e);
  }
  
  public void mouseExited(MouseEvent e) {
    System.out.println( "---- mouseExited" );
    printEvents(e);
  }
  
  public void mousePressed(MouseEvent e) {
    System.out.println( "---- mousePressed" );
    printEvents(e);
  }
  
  public void mouseReleased(MouseEvent e)  {
    System.out.println( "---- mouseReleased" );
    printEvents(e);
  }
  
  
  protected void printEvents(MouseEvent e) {
    int button = e.getButton();
    switch(button) {
      case MouseEvent.BUTTON1: System.out.println( "Button 1" ); break;
      case MouseEvent.BUTTON2: System.out.println( "Button 2" ); break;
      case MouseEvent.BUTTON3: System.out.println( "Button 3" ); break;
    }
    
    int clickCount = e.getClickCount();
    if (clickCount > 0 ) System.out.println( "Click count: " + clickCount );
  }
  
  
  public static void main ( String[] args ) {
    JPanel panel = new JPanel();
    panel.addMouseListener(new Mouse() );
    
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setContentPane( panel );
    frame.setSize(300,300);
    frame.setVisible(true);
    
    
    JFileChooser fc = new JFileChooser();
    int returnVal = fc.showOpenDialog(null);
  }
  
} 
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
For Test 1, You must select the subfolder (using a single click) and then physically click on the Open button to navigate on the JFileChooser. However other standard java swing tools may not have a work around (e.g. double click to edit a JTable cell).

For Test 2, instead of looking for the e.getClickCount() >= 2 on the MouseClicked() method of the MouseListener interface, get it from mouseReleased() instead.

Comments
EVALUATION No response from submitter for more then three month. If you have additional info then post it.
22-10-2007

EVALUATION On windows we ignore smudge factor since JDK6 (6404008) so the only reason is that the pointer was dragged just after the first click. From awt_Component.cpp : if (!m_firstDragSent) { SendMouseEvent(java_awt_event_MouseEvent_MOUSE_CLICKED, nowMillisUTC(), x, y, GetJavaModifiers(), clickCount, JNI_FALSE, GetButton(button)); } To get sure we have to trace the AWT code with stylus plugged in.
10-07-2007