Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -713,7 +713,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);
prsadhuk marked this conversation as resolved.
Show resolved Hide resolved
SwingUtilities.invokeAndWait(backgroundFrame::dispose);
}

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