test/java/awt/FullScreen/8013581/bug8013581.java

Print this page

        

@@ -27,11 +27,10 @@
  * @summary [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
  * @author leonid.romanov@oracle.com
  * @run main bug8013581
  */
 
-import sun.awt.*;
 import java.awt.*;
 import java.awt.event.*;
 
 public class bug8013581 {
     private static Frame frame;

@@ -40,32 +39,31 @@
     public static void main(String[] args) throws Exception {
         final GraphicsEnvironment ge = GraphicsEnvironment
                 .getLocalGraphicsEnvironment();
         final GraphicsDevice[] devices = ge.getScreenDevices();
 
-        final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
         final Robot robot = new Robot();
         robot.setAutoDelay(50);
 
         createAndShowGUI();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Exception error = null;
         for (final GraphicsDevice device : devices) {
             if (!device.isFullScreenSupported()) {
                 continue;
             }
 
             device.setFullScreenWindow(frame);
-            sleep();
+            sleep(robot);
 
             robot.keyPress(KeyEvent.VK_A);
             robot.keyRelease(KeyEvent.VK_A);
-            toolkit.realSync();
+            robot.waitForIdle();
 
             device.setFullScreenWindow(null);
-            sleep();
+            sleep(robot);
 
             if (listenerCallCounter != 2) {
                 error = new Exception("Test failed: KeyListener called " + listenerCallCounter + " times instead of 2!");
                 break;
             }

@@ -96,12 +94,12 @@
 
         frame.setUndecorated(true);
         frame.setVisible(true);
     }
 
-    private static void sleep() {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+    private static void sleep(Robot robot) {
+        robot.waitForIdle();
         try {
             Thread.sleep(2000);
         } catch (InterruptedException ignored) {
         }
     }