JDK-8230660 : Java 8 - AWT Robot mouseMove fails on Windows 10 1709
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-08-20
  • Updated: 2019-09-05
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-poolUnresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10 - 1709


A DESCRIPTION OF THE PROBLEM :
JDK-8196030 (https://bugs.openjdk.java.net/browse/JDK-8196030?attachmentOrder=desc) contains in the first comment that the ticket does not affect Java 8.  Unfortunately, that is not true.  Running the SimpleAWTRobotTest.java (found in the original ticket) on some Windows 10 - 1709 systems fail, because the Robot.mouseMove() moves the mouse to the wrong part of the screen.

Failing systems need to be 1080p with a 15" or less monitor.  Even with the display scaling set to 100%, the AWT Robot still moves the wrong coordinates.

I've seen it fail at 1080p 100% scale on a 13" laptop and a 15" laptop, but pass on a 65" screen.  It seems Windows is "compensating" for the smaller screen and Java is not handling it.  It seem to work reliably under Linux.

See discussion of the problem affecting AssertJ Swing here: https://github.com/joel-costigliola/assertj-swing/issues/235

This ticket is a request to backport JDK-8196030 to Java 8.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See attached test (lifted verbatim from ORC-8196030).

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Move the mouse to the correct part of the screen.
ACTUAL -
Moves the mouse to the wrong part of the screen.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Robot;
import java.awt.event.InputEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

/**
 * Simple standalone AWT robot test.
 */
public class SimpleAWTRobotTest {

    private boolean clicked = false;

    public void initGUI() {
        JFrame frame = new JFrame("Simple AWT Robot Test");
        frame.setLayout(new BorderLayout());
        frame.setUndecorated(true);
        frame.setLocation(300, 300);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.setPreferredSize(new Dimension(100, 100));
        frame.add(panel);

        JButton button = new JButton("Click me");
        button.addActionListener(e -> clicked = true);
        panel.add(button, BorderLayout.CENTER);

        frame.pack();
        frame.setVisible(true);
    }

    public void test() throws Exception {
        final Robot robot = new Robot();

        SwingUtilities.invokeAndWait(() -> {
            this.initGUI();
        });
        SwingUtilities.invokeAndWait(() -> {
            //robot.mouseMove(0, 0);
            robot.mouseMove(350, 350);
        });
        Thread.sleep(500);
        SwingUtilities.invokeAndWait(() -> {
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        });
        Thread.sleep(500);
        SwingUtilities.invokeAndWait(() -> {
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        });
        Thread.sleep(500);
        if (clicked) {
            System.out.println("PASSED");
        } else {
            System.out.println("*** FAILED");
        }
        System.exit(0);
    }

    public static void main(String[] args) throws Exception {
        new SimpleAWTRobotTest().test();
    }
    
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use Java 11

FREQUENCY : always



Comments
Issue is reported with JDK 8u221 in Windows 10 v1709, where Robot.mouseMove() moves the mouse to the wrong part of the screen. Procondition for verification is that the monitor must be 15" or less. Checked this for Windows 10 v1809 and 14" screen and could confirm the issue with JDK 8. Result: ========== 8: Fail 8u221: Fail 9: Pass 12.0.2: Pass 13 ea b33: Pass 14 ea b12: Pass To verify, run the attached program with respective JDK versions.
05-09-2019