< prev index next >

test/java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java

Print this page

        

@@ -20,19 +20,15 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
 
-import com.sun.awt.AWTUtilities;
-import java.awt.Frame;
-import java.awt.Panel;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Robot;
+import java.awt.*;
 import java.awt.event.InputEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.lang.reflect.Method;
 import javax.swing.JButton;
 import javax.swing.SwingUtilities;
 import test.java.awt.regtesthelpers.Util;
 
 /**

@@ -44,12 +40,11 @@
 /*
 @test
 @bug 6776743
 @summary Opaque overlapping test for each AWT component
 @library ../../regtesthelpers
-@modules java.desktop/com.sun.awt
-         java.desktop/java.awt.peer
+@modules java.desktop/java.awt.peer
          java.desktop/sun.awt
 @build Util
 @run main OpaqueOverlapping
  */
 public class OpaqueOverlapping extends OverlappingTestBase {

@@ -130,16 +125,14 @@
         // Now perform the click at this point for 9 times
         // In the middle of the process toggle the opaque
         // flag value.
         for (int i = 0; i < 9; ++i) {
             if (i == 3) {
-                AWTUtilities.setComponentMixingCutoutShape(light,
-                        new Rectangle());
+                setMixingCutoutShape(light, new Rectangle());
             }
             if (i == 6) {
-                AWTUtilities.setComponentMixingCutoutShape(light,
-                        null);
+                setMixingCutoutShape(light, null);
             }
 
             robot.mousePress(InputEvent.BUTTON1_MASK);
             robot.mouseRelease(InputEvent.BUTTON1_MASK);
             Util.waitForIdle(robot);

@@ -161,10 +154,26 @@
         }
         return result;
     }
 
     // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
-    public static void main(String args[]) throws InterruptedException {
+    public static void main(String args[]) throws Exception {
+        setMixingCutoutShapeMethod = Component.class.
+                getDeclaredMethod("setMixingCutoutShape", Shape.class);
+        setMixingCutoutShapeMethod.setAccessible(true);
+
         instance = new OpaqueOverlapping();
         OverlappingTestBase.doMain(args);
     }
+
+    private static Method setMixingCutoutShapeMethod;
+
+    private static void setMixingCutoutShape(Component comp, Shape shape) {
+        try {
+            setMixingCutoutShapeMethod.invoke(comp, shape);
+        } catch (Exception e) {
+            throw new RuntimeException("Cannot execute setMixingCutoutShape " +
+                    "method");
+        }
+    }
+
 }
< prev index next >