JDK-4027756 : Mouse events delivered to wrong components.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1997-01-24
  • Updated: 1998-05-07
  • Resolved: 1998-05-07
Related Reports
Duplicate :  
Description

Name: mc57594			Date: 01/23/97


Compile and run TestApplet class. You'll see two canvases -
"Foo" and "Bar". When you press or release mouse buttons in this
canvases strings "<Canvas name> Mouse pressed" or "<name> Mouse
released" are printed to the console. If you press mouse button in some
canvas, quickly drag mouse into another and release it there, you should
see something like this:
   Foo Mouse pressed
   Foo Mouse released     
But sometimes you can see:
   Foo Mouse pressed
   Bar Mouse released
I think it's wrong behaviour because all mouse input should be delivered
to the component where mouse was pressed.

--------------------- Source --------------------------------------
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class TestApplet extends Applet {
    public void init () {
	setLayout (null);
	TestCanvas tc1 = new TestCanvas ("Foo");
	TestCanvas tc2 = new TestCanvas ("Bar");
	add (tc1);
	add (tc2);
	tc1.reshape (0,  0, 40, 20);
	tc2.reshape (42, 0, 40, 20);
	show ();
	tc1.show ();
	tc2.show ();
    }
}


public class TestCanvas extends Canvas {
    String m_name;
    public TestCanvas (String name) {
	super ();
	m_name = name;
	addMouseListener (
	    new MouseAdapter () {
	        public void mousePressed (MouseEvent e) {
		    System.out.println (m_name + "  Pressed");
		}
		public void mouseReleased (MouseEvent e) {
	   	    System.out.println (m_name + "  Released");
		}
	    }
	);
    }
    public void paint (Graphics g) {
	g.setColor   (Color.black);
	g.drawRect   (0, 0, size ().width - 1, size ().height - 1);
	g.drawString (m_name, 5, 15);
    }
}

----------------------- End of source -----------------------------
======================================================================

Comments
EVALUATION Verified using Spy++ -- is either a Windows bug or (more likely) a bug in our mouse message pre-processing.
11-06-2004

WORK AROUND Name: mc57594 Date: 01/23/97 None ======================================================================
11-06-2004

PUBLIC COMMENTS duplicate of 4035189
10-06-2004