JDK-4097813 : Mouse entered events give the wrong coordinate
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1997-12-08
  • Updated: 2000-04-27
  • Resolved: 2000-04-27
Related Reports
Duplicate :  
Description

Name: joT67522			Date: 12/08/97


The code below illustrates the problem. Take any two
components and add a mouselistener for enter and
exit events for each component. Place the components
in a container such that they are adjoining.
As the mouse exits component A and enters component
B, the mouse entered event for component B gives the
coordinate at which the mouse exited for component
A.

NB. this is a serious problem in drawing applications.

Here is some code:
/*
 * This applet demonstrates a bug with the mouse entered event.
 * Two panels are placed side by side. When the mouse moves across the
 * border between the panels, a mouse exit event is generated and then
 * an entered event.
 * Note that the coordinate for both is the same - the coordinate for
 * the mouse entered event should be the point at which the mouse
 * entered the panel, not the point at which the mouse exited the
 * adjoining panel.
 *
 * Channing Walton
 * ###@###.###
 */

import java.awt.*;
import java.applet.*;

public class Applet1 extends Applet
{
	public void init()
	{
		
		setLayout(null);
		panel1 = new java.awt.Panel();
		panel1.setBounds(0,0,100,100);
		panel1.setBackground(new Color(12632256));
		add(panel1);
		panel2 = new java.awt.Panel();
		panel2.setBounds(100,0,100,100);
		panel2.setBackground(new Color(16756655));
		add(panel2);
	
		SymMouse aSymMouse = new SymMouse();
		panel1.addMouseListener(aSymMouse);
		panel2.addMouseListener(aSymMouse);
	}
	
	java.awt.Panel panel1;
	java.awt.Panel panel2;

	class SymMouse extends java.awt.event.MouseAdapter
	{
		public void mouseExited(java.awt.event.MouseEvent event)
		{
			System.out.println("Exit: " + event.getPoint());
		}

		public void mouseEntered(java.awt.event.MouseEvent event)
		{
			System.out.println("Entered: " + event.getPoint());
		}
	}
}
(Review ID: 21532)
======================================================================

Comments
EVALUATION Name: rrT76497 Date: 07/24/98 ============================================================================================ R Chandrasekar / SIP tech, July 23,1998 This is a valid bug which exists on all platforms. The behaviour is the same in the following platforms. jdk 1.1.7 for Windows 95, Windows NT jdk 1.2beta4-H for Windows 95, Windows NT jdk 1.1.7 for Solaris 2.6 for SPARC jdk 1.2beta4-K for Solaris 2.6 for SPARC jdk 1.1.7 for Solaris 2.6 for x86 jdk 1.2beta4-J for Solaris 2.6 for x86 As the mouse exits component A and enters component B, the mouse entered event for component B gives the coordinate at which the mouse exited for component. ============================================================================================ ======================================================================
11-06-2004

WORK AROUND Name: joT67522 Date: 12/08/97 There is no work around I know of. ======================================================================
11-06-2004

PUBLIC COMMENTS 4/27/2000 kevin.ryan@eng -- dupe of # 4059534
10-06-2004