Skip to content

Commit 05ad02f

Browse files
committed
8268284: javax/swing/JComponent/7154030/bug7154030.java fails with "Exception: Failed to hide opaque button"
Backport-of: 534f00510e26da8deb891b4184c860ec64991b8f
1 parent 143cc64 commit 05ad02f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/jdk/javax/swing/JComponent/7154030/bug7154030.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class bug7154030 {
5757

5858
private static JButton button = null;
5959
private static JFrame frame;
60-
private static int locx, locy, frw, frh;
60+
private static volatile int locx, locy, frw, frh;
6161

6262
public static void main(String[] args) throws Exception {
6363
try {
@@ -76,6 +76,7 @@ public void run() {
7676
JDesktopPane desktop = new JDesktopPane();
7777
button = new JButton("button");
7878
frame = new JFrame();
79+
frame.setUndecorated(true);
7980

8081
button.setSize(200, 200);
8182
button.setLocation(100, 100);
@@ -102,12 +103,14 @@ public void run() {
102103

103104
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
104105
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
105-
Rectangle bounds = frame.getBounds();
106-
Insets insets = frame.getInsets();
107-
locx = bounds.x + insets.left;
108-
locy = bounds.y + insets.top;
109-
frw = bounds.width - insets.left - insets.right;
110-
frh = bounds.height - insets.top - insets.bottom;
106+
SwingUtilities.invokeAndWait(() -> {
107+
Rectangle bounds = frame.getBounds();
108+
Insets insets = frame.getInsets();
109+
locx = bounds.x + insets.left;
110+
locy = bounds.y + insets.top;
111+
frw = bounds.width - insets.left - insets.right;
112+
frh = bounds.height - insets.top - insets.bottom;
113+
});
111114

112115
BufferedImage fullScreen = robot.createScreenCapture(screen);
113116
Graphics g = fullScreen.getGraphics();

0 commit comments

Comments
 (0)