author | art |
Wed, 06 May 2009 12:39:23 +0400 | |
changeset 2759 | a6629ca69b70 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2759
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
1 |
/* |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
2 |
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
4 |
* |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
8 |
* |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
13 |
* accompanied this code). |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
14 |
* |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
18 |
* |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
21 |
* have any questions. |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
22 |
*/ |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
23 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
24 |
/* |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
25 |
* @test |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
26 |
* @bug 6837004 |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
27 |
* @summary Checks that non-opaque window can be made a fullscreen window |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
28 |
* @author Artem Ananiev |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
29 |
* @run main TranslucentWindow |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
30 |
*/ |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
31 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
32 |
import java.awt.*; |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
33 |
import java.awt.geom.*; |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
34 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
35 |
import static java.awt.GraphicsDevice.WindowTranslucency.*; |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
36 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
37 |
import sun.awt.SunToolkit; |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
38 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
39 |
public class TranslucentWindow { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
40 |
public static void main(String args[]) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
41 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
42 |
GraphicsDevice gd = ge.getDefaultScreenDevice(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
43 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
44 |
Frame f = new Frame("Test frame"); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
45 |
f.setBounds(100, 100, 320, 240); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
46 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
47 |
// First, check it can be made fullscreen window without any effects applied |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
48 |
gd.setFullScreenWindow(f); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
49 |
((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
50 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
51 |
gd.setFullScreenWindow(null); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
52 |
((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
53 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
54 |
// Second, check if it applying any effects doesn't prevent the window |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
55 |
// from going into the fullscreen mode |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
56 |
if (gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT)) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
57 |
f.setShape(new Ellipse2D.Float(0, 0, f.getWidth(), f.getHeight())); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
58 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
59 |
if (gd.isWindowTranslucencySupported(TRANSLUCENT)) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
60 |
f.setOpacity(0.5f); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
61 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
62 |
if (gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT)) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
63 |
f.setBackground(new Color(0, 0, 0, 128)); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
64 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
65 |
gd.setFullScreenWindow(f); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
66 |
((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
67 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
68 |
// Third, make sure all the effects are unset when entering the fullscreen mode |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
69 |
if (f.getShape() != null) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
70 |
throw new RuntimeException("Test FAILED: fullscreen window shape is not null"); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
71 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
72 |
if (Math.abs(f.getOpacity() - 1.0f) > 1e-4) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
73 |
throw new RuntimeException("Test FAILED: fullscreen window opacity is not 1.0f"); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
74 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
75 |
Color bgColor = f.getBackground(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
76 |
if ((bgColor != null) && (bgColor.getAlpha() != 255)) { |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
77 |
throw new RuntimeException("Test FAILED: fullscreen window background color is not opaque"); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
78 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
79 |
|
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
80 |
f.dispose(); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
81 |
System.out.println("Test PASSED"); |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
82 |
} |
a6629ca69b70
6837004: java.awt.GraphicsDevice.setFullScreenWindow throws NPE for windows with background color not set
art
parents:
diff
changeset
|
83 |
} |