From 63209dd84e66e478a0ed2fdd0235e7da0988ea1c Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 6 Nov 2020 03:39:13 +0000 Subject: [PATCH] Used window getbounds --- .../javax/swing/JComponent/7154030/bug7154030.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/jdk/javax/swing/JComponent/7154030/bug7154030.java b/test/jdk/javax/swing/JComponent/7154030/bug7154030.java index 68d87a115fb7c..7654eca3eab59 100644 --- a/test/jdk/javax/swing/JComponent/7154030/bug7154030.java +++ b/test/jdk/javax/swing/JComponent/7154030/bug7154030.java @@ -33,7 +33,6 @@ import java.awt.AWTException; import java.awt.AlphaComposite; import java.awt.Color; -import java.awt.GraphicsEnvironment; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; @@ -90,18 +89,18 @@ public void run() { frame.setContentPane(desktop); frame.setSize(300, 300); - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(). - getBounds(); - locx = rect.width/2; - locy = rect.height/2; - frame.setLocation(locx, locy); + frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } }); robot.waitForIdle(1000); + + Rectangle bounds = frame.getBounds(); + locx = bounds.x; + locy = bounds.y; + imageInit = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300)); SwingUtilities.invokeAndWait(new Runnable() {