8275851: Deproblemlist open/test/jdk/javax/swing/JComponent/6683775/bug6683775.java

Reviewed-by: serb
This commit is contained in:
Prasanta Sadhukhan 2021-10-27 10:24:21 +00:00
parent b3f45f868d
commit 485d65865e
2 changed files with 33 additions and 26 deletions
test/jdk
ProblemList.txt
javax/swing/JComponent/6683775

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

@ -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
@ -46,6 +46,10 @@ 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(
@ -53,35 +57,39 @@ public class bug6683775 {
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);
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);
});
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.waitForIdle();
robot.delay(1000);
//robot.getPixelColor() didn't work right for some reason
BufferedImage capture =
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));
//robot.getPixelColor() didn't work right for some reason
capture =
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));
SwingUtilities.invokeAndWait(testFrame::dispose);
} finally {
SwingUtilities.invokeAndWait(testFrame::dispose);
SwingUtilities.invokeAndWait(backgroundFrame::dispose);
}
int redRGB = Color.RED.getRGB();
if (redRGB != capture.getRGB(SIZE/2, SIZE/2)) {