提交 eaa3d6c4 编写于 作者: A anthony

7039616: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java should be updated

Summary: Consider the test passed if the system does not support translucency
Reviewed-by: art
上级 b6f3b36b
...@@ -37,11 +37,12 @@ import javax.swing.*; ...@@ -37,11 +37,12 @@ import javax.swing.*;
public class TranslucentJAppletTest { public class TranslucentJAppletTest {
private static volatile GraphicsConfiguration graphicsConfig = null;
private static JFrame frame; private static JFrame frame;
private static volatile boolean paintComponentCalled = false; private static volatile boolean paintComponentCalled = false;
private static void initAndShowGUI() { private static void initAndShowGUI() {
frame = new JFrame(); frame = new JFrame(graphicsConfig);
JApplet applet = new JApplet(); JApplet applet = new JApplet();
applet.setBackground(new Color(0, 0, 0, 0)); applet.setBackground(new Color(0, 0, 0, 0));
JPanel panel = new JPanel() { JPanel panel = new JPanel() {
...@@ -66,6 +67,27 @@ public class TranslucentJAppletTest { ...@@ -66,6 +67,27 @@ public class TranslucentJAppletTest {
{ {
sun.awt.SunToolkit tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit(); sun.awt.SunToolkit tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit();
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice gd : ge.getScreenDevices()) {
if (gd.isWindowTranslucencySupported(
GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT))
{
for (GraphicsConfiguration gc : gd.getConfigurations()) {
if (gc.isTranslucencyCapable()) {
graphicsConfig = gc;
break;
}
}
}
if (graphicsConfig != null) {
break;
}
}
if (graphicsConfig == null) {
System.out.println("The system does not support translucency. Consider the test passed.");
return;
}
Robot r = new Robot(); Robot r = new Robot();
Color color1 = r.getPixelColor(100, 100); // (0, 0) in frame coordinates Color color1 = r.getPixelColor(100, 100); // (0, 0) in frame coordinates
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册