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);
}
}
======================================================================