Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8275851: Deproblemlist open/test/jdk/javax/swing/JComponent/6683775/b…
…ug6683775.java

Reviewed-by: serb
  • Loading branch information
prsadhuk committed Oct 27, 2021
1 parent b3f45f8 commit 485d658
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -705,7 +705,6 @@ javax/sound/midi/Sequencer/Looping.java 8136897 generic-all
javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all,windows-all

javax/swing/border/TestTitledBorderLeak.java 8213531 linux-all
javax/swing/JComponent/6683775/bug6683775.java 8172337 generic-all
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 8233582 linux-all
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 8233582 linux-all
javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java 8194128 macosx-all
Expand Down
68 changes: 38 additions & 30 deletions test/jdk/javax/swing/JComponent/6683775/bug6683775.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -46,42 +46,50 @@ public class bug6683775 {
static final int LOC = 100,
SIZE = 200;

static JFrame testFrame;
static JFrame backgroundFrame;
static BufferedImage capture;

public static void main(String[] args) throws Exception {
GraphicsConfiguration gc = getGC();
if (gc == null || !gc.getDevice().isWindowTranslucencySupported(
GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
return;
}
Robot robot = new Robot();
final JFrame testFrame = new JFrame(gc);

SwingUtilities.invokeAndWait(() -> {
JFrame backgroundFrame = new JFrame("Background frame");
backgroundFrame.setUndecorated(true);
JPanel panel = new JPanel();
panel.setBackground(Color.RED);
backgroundFrame.add(panel);
backgroundFrame.setBounds(LOC, LOC, SIZE, SIZE);
backgroundFrame.setVisible(true);

testFrame.setUndecorated(true);
JPanel p = new JPanel();
p.setOpaque(false);
testFrame.add(p);
setOpaque(testFrame, false);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setBounds(LOC, LOC, SIZE, SIZE);
testFrame.setVisible(true);
});

robot.waitForIdle();
Thread.sleep(1500);

//robot.getPixelColor() didn't work right for some reason
BufferedImage capture =
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));

SwingUtilities.invokeAndWait(testFrame::dispose);

try {
SwingUtilities.invokeAndWait(() -> {
testFrame = new JFrame(gc);
backgroundFrame = new JFrame("Background frame");
backgroundFrame.setUndecorated(true);
JPanel panel = new JPanel();
panel.setBackground(Color.RED);
backgroundFrame.add(panel);
backgroundFrame.setBounds(LOC, LOC, SIZE, SIZE);
backgroundFrame.setVisible(true);

testFrame.setUndecorated(true);
JPanel p = new JPanel();
p.setOpaque(false);
testFrame.add(p);
setOpaque(testFrame, false);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setBounds(LOC, LOC, SIZE, SIZE);
testFrame.setVisible(true);
});

robot.waitForIdle();
robot.delay(1000);

//robot.getPixelColor() didn't work right for some reason
capture =
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));

} finally {
SwingUtilities.invokeAndWait(testFrame::dispose);
SwingUtilities.invokeAndWait(backgroundFrame::dispose);
}

int redRGB = Color.RED.getRGB();
if (redRGB != capture.getRGB(SIZE/2, SIZE/2)) {
Expand Down

1 comment on commit 485d658

@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.