JDK-4874673 : MOUSE MOVED EVENTS SENT WHEN THE CURSOR IS BEING DRAGGED IN THE MOUSE CLICK ZONE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.1_03
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-06-05
  • Updated: 2003-08-15
  • Resolved: 2003-07-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1_05 05Fixed
Description

Name: pa48320			Date: 06/05/2003

Due to a fix applied for Sun Bug ID 4731797 in 1.4.1_03, users now will receive mouse moved events when they are dragging their cursor. The mouse moved events are only sent when the cursor is being dragged in the "Mouse Click Zone". Once the cursor is outside this zone, then mouse dragged events are received. It seems like their should have been a time limit for when an event was suppose to be interpreted as a mouse clicked versus a mouse dragged. In the following test app, if a user drags the mouse in the area labeled as "Drag test area", you will see that once the mouse is pressed, a message is written out saying that dragging should begin. Once the drag begins, a user only receives mouse moved events until the user has dragged the mouse outside the click zone, the mouse dragged events are received. If the user drags the mouse back to where the drag began, the user will once again only receive mouse moved events. 

Also to note, because of this bug, this has changed the resizing behavior in the JTable. If a user goes to resize a column slowly, for the first couple pixels either way the column will not resize. Once the column resizing begins, the resize cursor is lost. The column can only be resized once the user has moved the cursor outside the mouse click zone. This is bad as a user has no way of resizing a column just a couple pixels and the fact the resize cursor is lost due to the JTable receiving the mouse moved events.

This is a regression from 1.4.1_02 as this all works fine for that release.

Overview:
Once the dragging is initiated the mouse click zone should no longer be looked at, and when dragging returns into the zone, one only receives mouse moved events instead of dragged events.

The problem also impacts scroll-bars.

import javax.swing.*;

public class MouseDraggedTest extends JFrame
{
	public MouseDraggedTest()
	{
		getContentPane().setLayout(new java.awt.BorderLayout());

		JTable table = new JTable(30, 5);
		JScrollPane pane = new JScrollPane(table);
		getContentPane().add(pane, java.awt.BorderLayout.NORTH);

		JPanel panel = new JPanel();
		panel.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), "Drag test area"));
		getContentPane().add(panel, java.awt.BorderLayout.CENTER);

		panel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
		{
			public void mouseDragged(java.awt.event.MouseEvent e)
			{
				System.out.println("Mouse Dragged"); //DA
			}

			public void mouseMoved(java.awt.event.MouseEvent e)
			{
				System.out.println("Mouse Moved"); 
			}
		});

		panel.addMouseListener(new java.awt.event.MouseAdapter()
		{
			public void mousePressed(java.awt.event.MouseEvent e)
			{
				System.out.println("Mouse Pressed, dragging should begin"); //DA
			}
		});

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(400, 700);
	}

	public static void main(String[] args)
	{
		MouseDraggedTest test = new MouseDraggedTest();
		test.setVisible(true);
	}
}
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.1_05 FIXED IN: 1.4.1_05 INTEGRATED IN: 1.4.1_05 VERIFIED IN: 1.4.1_05
14-06-2004

WORK AROUND Name: pa48320 Date: 06/05/2003 none ======================================================================
11-06-2004

EVALUATION This is only reproducible in 1.4.1_03 - not in 1.4.2 or 1.5.0. This is because the fix for 4731797 in 1.4.2 and 1.5.0 was different than the 1.4.1_03 fix, and didn't have this problem. ###@###.### 2003-06-05
05-06-2003