Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5039416
Votes 13
Synopsis REGRESSION: Extra mouse click dispatched after press-drag- release sequence.
Category java:classes_awt
Reported Against tiger-beta
Release Fixed mustang(b38), 5.0u5(b03) (Bug ID:2125768)
State 10-Fix Delivered, Verified, bug
Priority: 3-Medium
Related Bugs 6384053 , 4731797 , 6403381 , 6404008 , 6481521 , 6176814 , 4955581 , 4974936
Submit Date 28-APR-2004
Description


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


ADDITIONAL OS VERSION INFORMATION :
Linux fuji 2.4.20 #2 SMP Tue May 13 19:03:46 CEST 2003 i686 unknown unknown GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
none


A DESCRIPTION OF THE PROBLEM :
A mouse click event is dispatched after a mouse press-drag-release sequence has occurred. No click event should be generated if the mouse is dragged between the press and release events.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached test case.
2. Click, drag and release the mouse in the window.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Mouse pressed
Mouse dragged
...
Mouse dragged
Mouse released

ACTUAL -
Mouse pressed
Mouse dragged
...
Mouse dragged
Mouse released
Mouse clicked

Note the unexpected click event at the end.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
none


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ExtraClickDemonstration extends JComponent {

	public ExtraClickDemonstration() {
		addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				System.err.println("Mouse pressed");
			}
			
			public void mouseReleased(MouseEvent e) {
				System.err.println("Mouse released");
			}
			
			public void mouseClicked(MouseEvent e) {
				System.err.println("Mouse clicked");
			}
		});
		addMouseMotionListener(new MouseMotionAdapter() {
			public void mouseDragged(MouseEvent e) {
				System.err.println("Mouse dragged");
			}
		});
	}
	
	public static void main(String[] args) {
		JFrame frame = new JFrame("Extra Click Demonstration");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(new ExtraClickDemonstration(), BorderLayout.CENTER);
		frame.setSize(new Dimension(480, 300));
		frame.setVisible(true);
	}
}

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

Release Regression From : 1.4.2_04
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 260137) 
======================================================================
Work Around
Force the use of Motif toolkit instead of XAWT:
by either providing this parameter during startup:
 -Dawt.toolkit=sun.awt.motif.MToolkit
or by setting the following env. variable:
  AWT_TOOLKIT=MToolkit

  xxxxx@xxxxx   2005-2-10 22:33:13 GMT
Evaluation


This is XAWT specific problem.
  xxxxx@xxxxx   2004-04-29

======================================================================



The cause of the problem is in XWindow.java file.
We generate MOUSE_CLICKED on ButtonRelease if lastWindowRef references to the 
same component as "this".  But we do not clear lastWindowRef on MotionNotify
for some reason.
  xxxxx@xxxxx   2004-04-29

======================================================================

AWT_MULTICLICK_SMUDGE might be an appropriate item to use in this case. 
According to Motif's implementation ( canvas.c ) we assign NULL to lastPeer when  mouse being dragged. Seems that this is already fixed in Mustang b24. (6176814)

  xxxxx@xxxxx   2005-2-15 16:12:53 GMT

This buggy behaviour already fixed in 6176814. Going to open a SubCR.
  xxxxx@xxxxx   2005-2-22 12:42:12 GMT

The fix for this bug is not delivered into JDK5.0_01 yet. It will appear in JDK5.0_04.
  xxxxx@xxxxx   2005-03-09 09:00:41 GMT
Careful analysis shows that XAWT posts MouseEvent always but Motif in some cases doesn't post event at all. I mean MouseMoved/MouseDragged events only. This is because in XAWT if-statement (!clickCount) missed for some reasons.
  xxxxx@xxxxx   2005-04-06 12:05:13 GMT

This fix is on its way to JDK1.5.0_05 - expect it soon.
  xxxxx@xxxxx   2005-06-17 07:56:28 GMT
Posted Date : 2005-06-17 07:56:28.0

The fix affected both XAWT and Windows platform.
Posted Date : 2006-03-31 09:56:17.0
Comments
  
  Include a link with my name & email   

Submitted On 23-FEB-2005
danblanks
THIS BUG IS NOT FIXED

6176814  refers to a fix in 1.4.2, however this bug still occurs in 1.5.0_01.   Here is the specific version information:

java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)

This FUNDAMENTAL problem is a real killer for drawing programs.  


Submitted On 23-FEB-2005
ianamason
This bug will prevent me from using Java 1.5 for teaching Java.
danblanks is corrrect, this bug exists in:

java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)


Submitted On 03-MAR-2005
okidoky
> We generate MOUSE_CLICKED on ButtonRelease if lastWindowRef references to the same component as "this".

The mouseClicked event should *never* be generated when *any* drag event has occured.  The "evalutation" is inadequate and does not solve the problem.  Clearly this is a bonafide pure and utter bug right in people


Submitted On 15-JUN-2005
csmith@lnxi.com
This is still broken from 1.4 through 1.5 on Linux. Please fix it.


Submitted On 22-JUN-2005
ilu.design
still broken with 1.5.0_03 on linux


Submitted On 28-JUL-2005
okidoky
Not fixed on linux 32 bit java 1.5.0_03.
but
Fixed on linux 64 bit amd java 1.5.0_04.

Keep in mind though that Sun currently (incorrectly) classifies all AMD 64 bit chips for server applications only (no client VM, no webstart, plugin, etc).


Submitted On 04-DEC-2005
sunburned
This FUNDAMENTAL ERROR in java was discovered in JDK 1.5 beta and allowed to propagate through FIVE releases?  ANY OTHER SURPRISES?






PLEASE NOTE: JDK6 is formerly known as Project Mustang