JDK-8013593 : [macosx] Mouse location on the Y axis is misreported during drag and drop
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u10
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • Submitted: 2013-03-20
  • Updated: 2014-11-17
  • Resolved: 2013-05-14
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.
JDK 8
8Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
1.7.0_10

ADDITIONAL OS VERSION INFORMATION :
OS X 10.8.2

A DESCRIPTION OF THE PROBLEM :
On OS X and JDK 7, the following APIs misreport the mouse's location on the Y axis while a drag and drop operation is in progress:

MouseInfo.getPointerInfo().getLocation()
DragSourceDragEvent.getLocation()

The degree of error in the reported mouse location is related to the height of the drag image assigned to the TransferHandler that initiates the drag (via TransferHandler.setDragImage).  If the TransferHandler has a null drag image then the reported mouse location is still off by some pixels and it seems impossible to know by how many.

This bug exists on OS X + JDK7 only.  It does not occur on Windows 7 + JDK 7, nor does it occur on OS X + JDK6.

REGRESSION.  Last worked in version 6u31

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Initiate a drag and drop operation on Mac OS X and check the values of

MouseInfo.getPointerInfo().getLocation().y

before, during, and after the drag.  Notice that as soon as the drag begins the reported y location changes.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The value of MouseInfo.getPointerInfo().getLocation().y will be consistent with the mouse's true on screen location during the drag and drop operation.
ACTUAL -
The value of MouseInfo.getPointerInfo().getLocation().y is misreported while a drag and drop operation is in progress.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
It appears that the reported value of MouseInfo.getPointerInfo().getLocation().y is off by two times the height of the drag image while the drag and drop operation is in progress.

  To work around the problem, always assign a drag image to the TransferHandler.  If you have no drag image to use (and would normally set a null drag image), create a transparent BufferedImage and use it as the drag image instead.  This way the drag image will have a known height in all cases.

Then, when the application is running on OS X, all classes that call MouseInfo.getPointerInfo().getLocation().y while a drag and drop operation is progress should subtract 2 * dragImage.getHeight() from the value of MouseInfo.getPointerInfo().getLocation().y to get the mouse's true location on the screen.

This workaround applies to other API calls as well, such as DragSourceDragEvent.getLocation().y
Comments
The problem is already fixed in 8 by the fix for JDK-8005405. The fix will be backported to 7 soon.
14-05-2013

test case
30-04-2013