< prev index next >

src/java.desktop/share/classes/java/awt/Robot.java

Print this page

        

@@ -39,10 +39,11 @@
 
 import sun.awt.AWTPermissions;
 import sun.awt.ComponentFactory;
 import sun.awt.SunToolkit;
 import sun.awt.image.SunWritableRaster;
+import sun.swing.SwingUtilities2;
 
 /**
  * This class is used to generate native system input events
  * for the purposes of test automation, self-running demos, and
  * other applications where control of the mouse and keyboard

@@ -497,13 +498,19 @@
         bandmasks[2] = screenCapCM.getBlueMask();
 
         // need to sync the toolkit prior to grabbing the pixels since in some
         // cases rendering to the screen may be delayed
         Toolkit.getDefaultToolkit().sync();
-        AffineTransform tx = GraphicsEnvironment.
-                getLocalGraphicsEnvironment().getDefaultScreenDevice().
-                getDefaultConfiguration().getDefaultTransform();
+
+        GraphicsConfiguration gc = GraphicsEnvironment
+                .getLocalGraphicsEnvironment()
+                .getDefaultScreenDevice().
+                getDefaultConfiguration();
+        gc = SwingUtilities2.getGraphicsConfigurationAtPoint(
+                gc, screenRect.getCenterX(), screenRect.getCenterY());
+
+        AffineTransform tx = gc.getDefaultTransform();
         double uiScaleX = tx.getScaleX();
         double uiScaleY = tx.getScaleY();
         int pixels[];
 
         if (uiScaleX == 1 && uiScaleY == 1) {
< prev index next >