JDK-8151598 : [macosx] Component.getMousePosition() returns null for disabled windows in Mac machines
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • Submitted: 2016-03-10
  • Updated: 2017-10-06
  • Resolved: 2017-10-06
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
8-poolResolved
Related Reports
Duplicate :  
Description
On Mac OSX, Component.getMousePosition() returns a null value if the window/frame/dialog on which it is called is disabled. In Windows it returns a value as expected.

Product(s) tested: 8u75b10
OS/architecture: Mac OSX
Error log file (if present):  
Reproducible: Always
Reproducible on machine: All Mac machines
Is it a Regression: Not sure - Tested in 8u76, 8u72, and 8u45 and issue was reproducible on all.
Is it a platform specific issue: Yes

Comments
This issue is duplicate of JDK-8035568 which is already fixed in 9 b68 and backported to 8u131 b04. Below results confirms the same 8u111 - Fail 8u131 b03 - Fail 8u131 b04 - Pass 8u144 b32 - Pass Closing as duplicate JDK-8035568
06-10-2017

Hi Victor, As mentioned by Renjith, the issue is not observed on JDK 9, only observed on JDK 8.
18-03-2016

Manajit, The above code will not work, as there would be no mouse events generated when the frame is disabled because of the modal dialog. I changed it a bit: started a thread which tries to get the mouse position on frame every 5 seconds. new Thread(){ public void run() { while(true) { try { Thread.sleep(5000); System.out.println("Position of mouse in the frame is " + frame.getMousePosition()); } catch(Exception e) {e.printStackTrace();} } } }.start(); I tried running the program on 1.9-b110 and the issue was not reproducible there. Apparently the issue is only with 8 and not 9. In 8, the API will give the co-ordinates as long as the mouse pointer is kept on the frame after opening the dialog. If the pointer is moved out, and then brought back into the frame, it will return only null values for getMousePostion() afterwards.
18-03-2016

HI Renjith, As per my understanding of the problem description and discussion with you, the test case should be as below: import java.awt.Button; import java.awt.Dialog; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class GetMousePosition { private static Frame frame; private static Dialog dialog; public static void createAndShowGUI() { frame = new Frame(); frame.setSize(600, 600); frame.setLayout(new FlowLayout()); Button button = new Button("Click To Open Dialog"); button.setSize(100, 100); button.setLocation(200, 200); frame.add(button); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { dialog = new Dialog(frame, "Alert", true); dialog.setLayout(new FlowLayout()); Button ok = new Button("Ok"); dialog.setBounds(200, 200, 200, 200); ok.addActionListener ( new ActionListener() { public void actionPerformed( ActionEvent e ) { // Hide dialog GetMousePosition.dialog.setVisible(false); } }); dialog.add( new Label ("Click OK to continue")); dialog.add(ok); dialog.setVisible(true); } }); frame.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { System.out.println("mouseClicked event " + frame.getMousePosition()); } }); frame.setVisible(true); } public static void main(String[] args) { createAndShowGUI(); } } Please let me know.
17-03-2016

Does it affect 9?
15-03-2016

This was an observation made when trying out fixes for stabilizing AWT modality tests in functional test suite. So don't have any stand alone test code to provide. It should not be difficult to reproduce though, just need to open a modal dialog with owner as a window, by which the window gets disabled. Try to get mouse position on that window.
11-03-2016

Hi Renjith, Please provide the test code. Is it reproducible in 9?
11-03-2016