Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 5eb2091

Browse files
author
Alexander Zuev
committedMar 6, 2021
8261689: javax/swing/JComponent/7154030/bug7154030.java still fails with "Exception: Failed to hide opaque button"
Reviewed-by: aivanov, azvegint
1 parent 75a5be8 commit 5eb2091

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed
 

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

+25-8
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
import javax.swing.SwingUtilities;
3232

3333
import java.awt.Color;
34+
import java.awt.Dimension;
35+
import java.awt.Graphics;
3436
import java.awt.Insets;
3537
import java.awt.Rectangle;
38+
import java.awt.Toolkit;
3639
import java.awt.image.BufferedImage;
3740
import javax.imageio.ImageIO;
3841
import java.io.File;
@@ -81,25 +84,35 @@ public void run() {
8184
button.setOpaque(true);
8285
button.setVisible(false);
8386
desktop.add(button);
87+
desktop.setMinimumSize(new Dimension(300, 300));
88+
desktop.setMaximumSize(new Dimension(300, 300));
8489

8590
frame.setContentPane(desktop);
86-
frame.setSize(300, 300);
91+
frame.setMinimumSize(new Dimension(350, 350));
92+
frame.setMaximumSize(new Dimension(350, 350));
93+
frame.pack();
8794
frame.setLocationRelativeTo(null);
8895
frame.setVisible(true);
8996
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
9097
}
9198
});
9299

93-
robot.delay(1000);
94100
robot.waitForIdle(1000);
101+
robot.delay(1000);
95102

103+
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
104+
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
96105
Rectangle bounds = frame.getBounds();
97106
Insets insets = frame.getInsets();
98107
locx = bounds.x + insets.left;
99108
locy = bounds.y + insets.top;
100109
frw = bounds.width - insets.left - insets.right;
101110
frh = bounds.height - insets.top - insets.bottom;
102111

112+
BufferedImage fullScreen = robot.createScreenCapture(screen);
113+
Graphics g = fullScreen.getGraphics();
114+
g.setColor(Color.RED);
115+
g.drawRect(locx - 1, locy - 1, frw + 1, frh + 1);
103116
imageInit = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
104117

105118
SwingUtilities.invokeAndWait(new Runnable() {
@@ -115,6 +128,7 @@ public void run() {
115128
if (Util.compareBufferedImages(imageInit, imageShow)) {
116129
ImageIO.write(imageInit, "png", new File("imageInit.png"));
117130
ImageIO.write(imageShow, "png", new File("imageShow.png"));
131+
ImageIO.write(fullScreen, "png", new File("fullScreenInit.png"));
118132
throw new Exception("Failed to show opaque button");
119133
}
120134

@@ -133,6 +147,7 @@ public void run() {
133147
if (!Util.compareBufferedImages(imageInit, imageHide)) {
134148
ImageIO.write(imageInit, "png", new File("imageInit.png"));
135149
ImageIO.write(imageHide, "png", new File("imageHide.png"));
150+
ImageIO.write(fullScreen, "png", new File("fullScreenInit.png"));
136151
throw new Exception("Failed to hide opaque button");
137152
}
138153

@@ -160,6 +175,13 @@ public void run() {
160175
robot.waitForIdle(500);
161176
imageShow = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
162177

178+
if (Util.compareBufferedImages(imageInit, imageShow)) {
179+
ImageIO.write(imageInit, "png", new File("imageInit.png"));
180+
ImageIO.write(imageShow, "png", new File("imageShow.png"));
181+
ImageIO.write(fullScreen, "png", new File("fullScreenInit.png"));
182+
throw new Exception("Failed to show non-opaque button");
183+
}
184+
163185
SwingUtilities.invokeAndWait(new Runnable() {
164186

165187
@Override
@@ -168,18 +190,13 @@ public void run() {
168190
}
169191
});
170192

171-
if (Util.compareBufferedImages(imageInit, imageShow)) {
172-
ImageIO.write(imageInit, "png", new File("imageInit.png"));
173-
ImageIO.write(imageShow, "png", new File("imageShow.png"));
174-
throw new Exception("Failed to show non-opaque button");
175-
}
176-
177193
robot.waitForIdle(500);
178194
imageHide = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
179195

180196
if (!Util.compareBufferedImages(imageInit, imageHide)) {
181197
ImageIO.write(imageInit, "png", new File("imageInit.png"));
182198
ImageIO.write(imageHide, "png", new File("imageHide.png"));
199+
ImageIO.write(fullScreen, "png", new File("fullScreenInit.png"));
183200
throw new Exception("Failed to hide non-opaque button");
184201
}
185202
} finally {

0 commit comments

Comments
 (0)
This repository has been archived.