equal
deleted
inserted
replaced
31 |
31 |
32 import java.awt.*; |
32 import java.awt.*; |
33 import java.awt.event.*; |
33 import java.awt.event.*; |
34 |
34 |
35 import com.sun.awt.AWTUtilities; |
35 import com.sun.awt.AWTUtilities; |
36 import sun.awt.SunToolkit; |
|
37 |
36 |
38 public class WindowOpacity |
37 public class WindowOpacity |
39 { |
38 { |
40 //*** test-writer defined static variables go here *** |
39 //*** test-writer defined static variables go here *** |
41 |
40 |
42 private static void realSync() { |
41 private static Robot robot; |
43 ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); |
|
44 } |
|
45 |
42 |
46 |
43 |
47 private static void init() |
44 private static void init() |
48 { |
45 { |
49 //*** Create instructions for the user here *** |
46 //*** Create instructions for the user here *** |
58 |
55 |
59 if (!AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT)) { |
56 if (!AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT)) { |
60 System.out.println("Either the Toolkit or the native system does not support controlling the window opacity level."); |
57 System.out.println("Either the Toolkit or the native system does not support controlling the window opacity level."); |
61 pass(); |
58 pass(); |
62 } |
59 } |
|
60 try { |
|
61 robot = new Robot(); |
|
62 }catch(Exception ex) { |
|
63 ex.printStackTrace(); |
|
64 throw new RuntimeException ("Unexpected failure"); |
|
65 } |
63 |
66 |
64 boolean passed; |
67 boolean passed; |
65 |
68 |
66 Frame f = new Frame("Opacity test"); |
69 Frame f = new Frame("Opacity test"); |
67 f.setUndecorated(true); |
70 f.setUndecorated(true); |
135 |
138 |
136 |
139 |
137 f.setBounds(100, 100, 300, 200); |
140 f.setBounds(100, 100, 300, 200); |
138 f.setVisible(true); |
141 f.setVisible(true); |
139 |
142 |
140 realSync(); |
143 robot.waitForIdle(); |
141 |
144 |
142 curOpacity = AWTUtilities.getWindowOpacity(f); |
145 curOpacity = AWTUtilities.getWindowOpacity(f); |
143 if (curOpacity < 0.75f || curOpacity > 0.75f) { |
146 if (curOpacity < 0.75f || curOpacity > 0.75f) { |
144 fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity before showing the frame: " + curOpacity); |
147 fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity before showing the frame: " + curOpacity); |
145 } |
148 } |
146 |
149 |
147 |
150 |
148 |
151 |
149 AWTUtilities.setWindowOpacity(f, 0.5f); |
152 AWTUtilities.setWindowOpacity(f, 0.5f); |
150 realSync(); |
153 robot.waitForIdle(); |
151 |
154 |
152 curOpacity = AWTUtilities.getWindowOpacity(f); |
155 curOpacity = AWTUtilities.getWindowOpacity(f); |
153 if (curOpacity < 0.5f || curOpacity > 0.5f) { |
156 if (curOpacity < 0.5f || curOpacity > 0.5f) { |
154 fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity after showing the frame: " + curOpacity); |
157 fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity after showing the frame: " + curOpacity); |
155 } |
158 } |