Skip to content

Commit

Permalink
8268284: javax/swing/JComponent/7154030/bug7154030.java fails with "E…
Browse files Browse the repository at this point in the history
…xception: Failed to hide opaque button"

Backport-of: 534f00510e26da8deb891b4184c860ec64991b8f
  • Loading branch information
akashche committed Nov 9, 2021
1 parent 143cc64 commit 05ad02f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/jdk/javax/swing/JComponent/7154030/bug7154030.java
Expand Up @@ -57,7 +57,7 @@ public class bug7154030 {

private static JButton button = null;
private static JFrame frame;
private static int locx, locy, frw, frh;
private static volatile int locx, locy, frw, frh;

public static void main(String[] args) throws Exception {
try {
Expand All @@ -76,6 +76,7 @@ public void run() {
JDesktopPane desktop = new JDesktopPane();
button = new JButton("button");
frame = new JFrame();
frame.setUndecorated(true);

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

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
Rectangle bounds = frame.getBounds();
Insets insets = frame.getInsets();
locx = bounds.x + insets.left;
locy = bounds.y + insets.top;
frw = bounds.width - insets.left - insets.right;
frh = bounds.height - insets.top - insets.bottom;
SwingUtilities.invokeAndWait(() -> {
Rectangle bounds = frame.getBounds();
Insets insets = frame.getInsets();
locx = bounds.x + insets.left;
locy = bounds.y + insets.top;
frw = bounds.width - insets.left - insets.right;
frh = bounds.height - insets.top - insets.bottom;
});

BufferedImage fullScreen = robot.createScreenCapture(screen);
Graphics g = fullScreen.getGraphics();
Expand Down

1 comment on commit 05ad02f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.