8063106: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 1
authoryan
Mon, 10 Nov 2014 16:37:40 +0300
changeset 27764 4e79ff3e0602
parent 27763 1fba965925e8
child 27765 ce958253b829
8063106: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 1 Reviewed-by: pchelko, serb
jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java
jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java
jdk/test/java/awt/Window/GetWindowsTest/GetWindowsTest.java
jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html
jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.java
jdk/test/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java
jdk/test/java/awt/security/WarningWindowDisposeTest/policy
jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java
jdk/test/javax/swing/JComboBox/6406264/bug6406264.java
jdk/test/javax/swing/JComboBox/8015300/Test8015300.java
jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java
jdk/test/javax/swing/JComponent/6989617/bug6989617.java
jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java
jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java
jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java
jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java
jdk/test/javax/swing/JLayer/6824395/bug6824395.java
jdk/test/javax/swing/JPopupMenu/6583251/bug6583251.java
jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java
jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java
jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java
jdk/test/javax/swing/JScrollPane/6274267/bug6274267.java
jdk/test/javax/swing/JSpinner/8008657/bug8008657.java
jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java
jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java
jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java
jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java
jdk/test/javax/swing/JTable/8032874/bug8032874.java
jdk/test/javax/swing/JTextArea/7049024/bug7049024.java
jdk/test/javax/swing/JToolBar/4529206/bug4529206.java
jdk/test/javax/swing/JViewport/7107099/bug7107099.java
jdk/test/javax/swing/Popup/6514582/bug6514582.java
jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java
jdk/test/javax/swing/Security/6657138/ComponentTest.java
jdk/test/javax/swing/SwingTest.java
jdk/test/javax/swing/text/Utilities/bug7045593.java
jdk/test/javax/swing/text/View/8048110/bug8048110.java
jdk/test/javax/swing/text/html/7189299/bug7189299.java
jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java
jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java
jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java
--- a/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java	Mon Nov 10 16:37:40 2014 +0300
@@ -30,8 +30,7 @@
 
 import javax.swing.*;
 import java.awt.Graphics;
-import java.awt.Toolkit;
-import sun.awt.SunToolkit;
+import java.awt.Robot;
 
 public class bug8016551 {
     private static volatile RuntimeException exception = null;
@@ -64,8 +63,8 @@
             }
         });
 
-        SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
-        tk.realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
 
         if (exception != null) {
             throw exception;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6383903
+  @summary REGRESSION: componentMoved is now getting called for some hidden components
+  @author andrei.dmitriev: area=awt.component
+  @run main CompEventOnHiddenComponent
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class CompEventOnHiddenComponent
+{
+    transient static boolean moved = false;
+    transient static boolean resized = false;
+
+    transient static boolean ancestor_moved = false;
+    transient static boolean ancestor_resized = false;
+    static String passed = "";
+
+    private static void init()
+    {
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test, simply wait until it is done.",
+            "The result (passed or failed) will be shown in the",
+            "message window below."
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        Robot robot;
+        try {
+            robot = new Robot();
+        }catch(Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException("Unexpected failure");
+        }
+
+        EventQueue.invokeLater(new Runnable(){
+                public void run(){
+                    JFrame f = new JFrame("JFrame");
+                    JButton b = new JButton("JButton");
+                    f.add(b);
+                    new JOptionPane().
+                        createInternalFrame(b, "Test").
+                        addComponentListener(new ComponentAdapter() {
+                                public void componentMoved(ComponentEvent e) {
+                                    moved = true;
+                                    System.out.println(e);
+                                }
+                                public void componentResized(ComponentEvent e) {
+                                    resized = true;
+                                    System.out.println(e);
+                                }
+                            });
+                }
+            });
+
+        robot.waitForIdle();
+
+        if (moved || resized){
+            passed = "Hidden component got COMPONENT_MOVED or COMPONENT_RESIZED event";
+        } else {
+            System.out.println("Stage 1 passed.");
+        }
+
+        EventQueue.invokeLater(new Runnable() {
+                public void run() {
+                    JFrame parentWindow = new JFrame("JFrame 1");
+                    JButton component = new JButton("JButton 1");;
+                    JButton smallButton = new JButton("Small Button");
+
+
+                    smallButton.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
+                            public void ancestorMoved(HierarchyEvent e) {
+                                ancestor_moved = true;
+                                System.out.println("SMALL COMPONENT >>>>>"+e);
+                            }
+                            public void ancestorResized(HierarchyEvent e) {
+                                ancestor_resized = true;
+                                System.out.println("SMALL COMPONENT >>>>>"+e);
+                            }
+                        });
+
+
+                    parentWindow.add(component);
+                    component.add(smallButton);
+
+                    component.setSize(100, 100);
+                    component.setLocation(100, 100);
+
+                }
+            });
+
+        robot.waitForIdle();
+
+        if (!ancestor_resized || !ancestor_moved){
+            passed = "Hidden component didn't get ANCESTOR event";
+        } else {
+            System.out.println("Stage 2 passed.");
+        }
+
+        robot.waitForIdle();
+
+        if (passed.equals("")){
+            CompEventOnHiddenComponent.pass();
+        } else {
+            CompEventOnHiddenComponent.fail(passed);
+        }
+
+    }//End  init()
+
+
+
+    /*****************************************************
+     * Standard Test Machinery Section
+     * DO NOT modify anything in this section -- it's a
+     * standard chunk of code which has all of the
+     * synchronisation necessary for the test harness.
+     * By keeping it the same in all tests, it is easier
+     * to read and understand someone else's test, as
+     * well as insuring that all tests behave correctly
+     * with the test harness.
+     * There is a section following this for test-
+     * classes
+     ******************************************************/
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+
+    }//main
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        Sysout.println( "The test passed." );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }//pass()
+
+    public static synchronized void fail()
+    {
+        //test writer didn't specify why test failed, so give generic
+        fail( "it just plain failed! :-)" );
+    }
+
+    public static synchronized void fail( String whyFailed )
+    {
+        Sysout.println( "The test failed: " + whyFailed );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }//fail()
+
+}// class CompEventOnHiddenComponent
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+//  them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         CompEventOnHiddenComponent.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         CompEventOnHiddenComponent.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+        System.out.println(messageIn);
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/GetWindowsTest/GetWindowsTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6322270
+  @summary Test for new API introduced in the fix for 6322270: Window.getWindows(),
+Window.getOwnerlessWindows() and Frame.getFrames()
+  @author artem.ananiev: area=awt.toplevel
+  @run main GetWindowsTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import java.util.*;
+
+public class GetWindowsTest
+{
+    private static Vector<Window> frames = new Vector<Window>();
+    private static Vector<Window> windows = new Vector<Window>();
+    private static Vector<Window> ownerless = new Vector<Window>();
+
+    private static void init()
+    {
+        Frame f1 = new Frame("F1");
+        f1.setBounds(100, 100, 100, 100);
+        f1.setVisible(true);
+        addToWindowsList(f1);
+
+        Dialog d1 = new Dialog(f1, "D1", Dialog.ModalityType.MODELESS);
+        d1.setBounds(120, 120, 100, 100);
+        d1.setVisible(true);
+        addToWindowsList(d1);
+
+        Window w1 = new Window(d1);
+        w1.setBounds(140, 140, 100, 100);
+        w1.setVisible(true);
+        addToWindowsList(w1);
+
+        Frame f2 = new Frame("F2");
+        f2.setBounds(300, 100, 100, 100);
+        f2.setVisible(true);
+        addToWindowsList(f2);
+
+        Window w2 = new Window(f2);
+        w2.setBounds(320, 120, 100, 100);
+        w2.setVisible(true);
+        addToWindowsList(w2);
+
+        Dialog d2 = new Dialog(f2, "D2", Dialog.ModalityType.MODELESS);
+        d2.setBounds(340, 140, 100, 100);
+        d2.setVisible(true);
+        addToWindowsList(d2);
+
+        Dialog d3 = new Dialog((Frame)null, "D3", Dialog.ModalityType.MODELESS);
+        d3.setBounds(500, 100, 100, 100);
+        d3.setVisible(true);
+        addToWindowsList(d3);
+
+        Dialog d4 = new Dialog(d3, "D4", Dialog.ModalityType.MODELESS);
+        d4.setBounds(520, 120, 100, 100);
+        d4.setVisible(true);
+        addToWindowsList(d4);
+
+        Window w3 = new Window((Frame)null);
+        w3.setBounds(700, 100, 100, 100);
+        w3.setVisible(true);
+        addToWindowsList(w3);
+
+        Window w4 = new Window(w3);
+        w4.setBounds(720, 120, 100, 100);
+        w4.setVisible(true);
+        addToWindowsList(w4);
+
+        try {
+            Robot robot = new Robot();
+            robot.waitForIdle();
+        }catch(Exception ex) {
+            ex.printStackTrace();
+            throw new Error("Unexpected failure");
+        }
+
+        Frame[] fl = Frame.getFrames();
+        Vector<Window> framesToCheck = new Vector<Window>();
+        for (Frame f : fl)
+        {
+            framesToCheck.add(f);
+        }
+        checkWindowsList(frames, framesToCheck, "Frame.getFrames()");
+
+        Window[] wl = Window.getWindows();
+        Vector<Window> windowsToCheck = new Vector<Window>();
+        for (Window w : wl)
+        {
+            windowsToCheck.add(w);
+        }
+        checkWindowsList(windows, windowsToCheck, "Window.getWindows()");
+
+        Window[] ol = Window.getOwnerlessWindows();
+        Vector<Window> ownerlessToCheck = new Vector<Window>();
+        for (Window o : ol)
+        {
+            ownerlessToCheck.add(o);
+        }
+        checkWindowsList(ownerless, ownerlessToCheck, "Window.getOwnerlessWindows()");
+
+        GetWindowsTest.pass();
+    }
+
+    private static void addToWindowsList(Window w)
+    {
+        if (w instanceof Frame)
+        {
+            frames.add(w);
+        }
+        windows.add(w);
+        if (w.getOwner() == null)
+        {
+            ownerless.add(w);
+        }
+    }
+
+    private static void checkWindowsList(Vector<Window> wl1, Vector<Window> wl2, String methodName)
+    {
+        if ((wl1.size() != wl2.size()) ||
+            !wl1.containsAll(wl2) ||
+            !wl2.containsAll(wl1))
+        {
+            fail("Test FAILED: method " + methodName + " returns incorrect list of windows");
+        }
+    }
+
+/*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+    }
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail()
+    {
+        //test writer didn't specify why test failed, so give generic
+        fail( "it just plain failed! :-)" );
+    }
+
+    public static synchronized void fail( String whyFailed )
+    {
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }
+}
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,23 @@
+<html>
+<!--  
+  @test
+  @bug 6260648
+  @summary Tests that WINDOW_DESTROY event can be handled by overriding handleEvent(). Also,
+tests that handleEvent() is not called by AWT if any listener is added to the component
+(i. e. when post-1.1 events schema is used)
+  @author artem.ananiev: area=awt.event
+  @run applet HandleWindowDestroyTest.html
+  -->
+<head>
+<title>  </title>
+</head>
+<body>
+
+<h1>HandleWindowDestroyTest<br>Bug ID: 6260648</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="HandleWindowDestroyTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  test
+  @bug 6260648
+  @summary Tests that WINDOW_DESTROY event can be handled by overriding handleEvent(). Also,
+tests that handleEvent() is not called by AWT if any listener is added to the component
+(i. e. when post-1.1 events schema is used)
+  @author artem.ananiev: area=awt.event
+  @run applet HandleWindowDestroyTest.html
+*/
+
+import java.applet.*;
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class HandleWindowDestroyTest extends Applet
+{
+    private volatile boolean handleEventCalled;
+
+    public void start ()
+    {
+        setSize (200,200);
+        setVisible(true);
+        validate();
+
+        Robot robot;
+        try {
+            robot = new Robot();
+        }catch(Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException("Unexpected failure");
+        }
+
+        Frame f = new Frame("Frame")
+        {
+            public boolean handleEvent(Event e)
+            {
+                if (e.id == Event.WINDOW_DESTROY)
+                {
+                    handleEventCalled = true;
+                }
+                return super.handleEvent(e);
+            }
+        };
+        f.setBounds(100, 100, 100, 100);
+        f.setVisible(true);
+        robot.waitForIdle();
+
+        handleEventCalled = false;
+        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(f, Event.WINDOW_DESTROY));
+        robot.waitForIdle();
+
+        if (!handleEventCalled)
+        {
+            throw new RuntimeException("Test FAILED: handleEvent() is not called");
+        }
+
+        f.addWindowListener(new WindowAdapter()
+        {
+        });
+
+        handleEventCalled = false;
+        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(f, Event.WINDOW_DESTROY));
+        robot.waitForIdle();
+
+        if (handleEventCalled)
+        {
+            throw new RuntimeException("Test FAILED: handleEvent() is called event with a listener added");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 5025858
+  @summary Tests that after programmatically moving or resizing a component,
+corresponding ComponentEvents are generated only once
+  @author artem.ananiev: area=awt.event
+  @run main/manual MovedResizedTwiceTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+/*
+  IMPORTANT: this test is made manual as some window managers may generate
+  strange events and that would lead to the test to fail. However, on most
+  popular platforms (windows, linux w/ KDE or GNOME, solaris w/ CDE or
+  GNOME) it usually passes successfully.
+*/
+
+public class MovedResizedTwiceTest
+{
+    private static volatile int componentMovedCount;
+    private static volatile int componentResizedCount;
+
+    private static volatile int rightX, rightY;
+
+    private static volatile boolean failed = false;
+
+    private static void init()
+    {
+        componentMovedCount = componentResizedCount = 0;
+
+        Robot robot;
+        try {
+            robot = new Robot();
+        }catch(Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException("Cannot create Robot: failure");
+        }
+
+        Frame f = new Frame("Frame F");
+        f.setLayout(null);
+        f.setBounds(100, 100, 100, 100);
+        f.add(new Button("Button"));
+
+        f.setVisible(true);
+        robot.waitForIdle();
+
+        ComponentListener cl = new ComponentAdapter()
+        {
+            public void componentMoved(ComponentEvent e)
+            {
+                componentMovedCount++;
+                Component c = (Component)e.getSource();
+                if (!(c instanceof Window))
+                {
+                    return;
+                }
+                Point p = c.getLocationOnScreen();
+                if ((p.x != rightX) || (p.y != rightY))
+                {
+                    System.err.println("Error: wrong location on screen after COMPONENT_MOVED");
+                    System.err.println("Location on screen is (" + p.x + ", " + p.y + ") against right location (" + rightX + ", " + rightY + ")");
+                    failed = true;
+                }
+            }
+            public void componentResized(ComponentEvent e)
+            {
+                componentResizedCount++;
+            }
+        };
+
+        f.addComponentListener(cl);
+
+        componentResizedCount = componentMovedCount = 0;
+        rightX = 100;
+        rightY = 100;
+        f.setSize(200, 200);
+        robot.waitForIdle();
+        checkResized("setSize", f);
+
+        componentResizedCount = componentMovedCount = 0;
+        rightX = 200;
+        rightY = 200;
+        f.setLocation(200, 200);
+        robot.waitForIdle();
+        checkMoved("setLocation", f);
+
+        componentResizedCount = componentMovedCount = 0;
+        rightX = 150;
+        rightY = 150;
+        f.setBounds(150, 150, 100, 100);
+        robot.waitForIdle();
+        checkResized("setBounds", f);
+        checkMoved("setBounds", f);
+
+        Button b = new Button("B");
+        b.setBounds(10, 10, 40, 40);
+        f.add(b);
+        robot.waitForIdle();
+
+        b.addComponentListener(cl);
+
+        componentResizedCount = componentMovedCount = 0;
+        b.setBounds(20, 20, 50, 50);
+        robot.waitForIdle();
+        checkMoved("setBounds", b);
+        checkResized("setBounds", b);
+        f.remove(b);
+
+        Component c = new Component() {};
+        c.setBounds(10, 10, 40, 40);
+        f.add(c);
+        robot.waitForIdle();
+
+        c.addComponentListener(cl);
+
+        componentResizedCount = componentMovedCount = 0;
+        c.setBounds(20, 20, 50, 50);
+        robot.waitForIdle();
+        checkMoved("setBounds", c);
+        checkResized("setBounds", c);
+        f.remove(c);
+
+        if (failed)
+        {
+            MovedResizedTwiceTest.fail("Test FAILED");
+        }
+        else
+        {
+            MovedResizedTwiceTest.pass();
+        }
+    }
+
+    private static void checkResized(String methodName, Component c)
+    {
+        String failMessage = null;
+        if (componentResizedCount == 1)
+        {
+            return;
+        }
+        else if (componentResizedCount == 0)
+        {
+            failMessage = "Test FAILED: COMPONENT_RESIZED is not sent after call to " + methodName + "()";
+        }
+        else
+        {
+            failMessage = "Test FAILED: COMPONENT_RESIZED is sent " + componentResizedCount + " + times after call to " + methodName + "()";
+        }
+        System.err.println("Failed component: " + c);
+        MovedResizedTwiceTest.fail(failMessage);
+    }
+
+    private static void checkMoved(String methodName, Component c)
+    {
+        String failMessage = null;
+        if (componentMovedCount == 1)
+        {
+            return;
+        }
+        if (componentMovedCount == 0)
+        {
+            failMessage = "Test FAILED: COMPONENT_MOVED is not sent after call to " + methodName + "()";
+        }
+        else
+        {
+            failMessage = "Test FAILED: COMPONENT_MOVED is sent " + componentMovedCount + " times after call to " + methodName + "()";
+        }
+        System.err.println("Failed component: " + c);
+        MovedResizedTwiceTest.fail(failMessage);
+    }
+
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch (TestPassedException e)
+        {
+            return;
+        }
+
+        try
+        {
+            Thread.sleep(sleepTime);
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            if (!testGeneratedInterrupt)
+            {
+                throw e;
+            }
+
+            testGeneratedInterrupt = false;
+
+            if (!theTestPassed)
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+    }
+
+    public static synchronized void setTimeoutTo(int seconds)
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        if (mainThread == Thread.currentThread())
+        {
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail()
+    {
+        fail("it just plain failed! :-)");
+    }
+
+    public static synchronized void fail(String whyFailed)
+    {
+        if (mainThread == Thread.currentThread())
+        {
+            throw new RuntimeException(whyFailed);
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }
+}
+
+class TestPassedException extends RuntimeException
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/policy	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,3 @@
+grant {
+        permission java.awt.AWTPermission "createRobot";
+};
--- a/jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java	Mon Nov 10 16:37:40 2014 +0300
@@ -31,12 +31,13 @@
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
 
-import sun.awt.SunToolkit;
-
 /**
  * @test
  * @bug 8009919
  * @author Sergey Bylokhov
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main JButtonPaintNPE
  */
 public final class JButtonPaintNPE {
 
@@ -69,9 +70,11 @@
 
     private static void sleep() {
         try {
-            ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
-            Thread.sleep(1000);
-        } catch (final InterruptedException ignored) {
-        }
+             ExtendedRobot robot = new ExtendedRobot();
+             robot.waitForIdle(1000);
+         }catch(Exception ex) {
+             ex.printStackTrace();
+             throw new Error("Unexpected Failure");
+         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/6406264/bug6406264.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 6406264
+   @summary Tests that JComboBox's focusable popup can be shown.
+   @author Mikhail Lapshin
+   @run main bug6406264
+ */
+
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+import javax.swing.plaf.basic.ComboPopup;
+import javax.swing.plaf.basic.BasicComboPopup;
+import java.awt.*;
+
+public class bug6406264 extends JComboBox {
+
+    static JFrame frame;
+    static bug6406264 comboBox;
+
+    public static void main(String[] args) throws Exception {
+
+        Robot robot = new Robot();
+        // Setup and show frame
+        SwingUtilities.invokeAndWait(
+                new Runnable() {
+                    public void run() {
+                        frame = new JFrame("JComboBox6406264 test");
+                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+                        comboBox = new bug6406264("One", "Two", "Three");
+                        frame.getContentPane().add(comboBox);
+
+                        frame.setLocationRelativeTo(null);
+                        frame.pack();
+                        frame.setVisible(true);
+                    }
+                }
+        );
+
+        robot.waitForIdle();
+
+        // Show popup
+        SwingUtilities.invokeAndWait(
+                new Runnable() {
+                    public void run() {
+                        comboBox.showPopup();
+                    }
+                });
+        robot.waitForIdle();
+
+        // Check that popup is visible
+        SwingUtilities.invokeAndWait(
+                new Runnable() {
+                    public void run() {
+                        if (comboBox.getUI().isPopupVisible(comboBox) == false)
+                        {
+                            throw new RuntimeException("A focusable popup is not visible " +
+                                    "in JComboBox!");
+                        }
+                    }
+                }
+        );
+
+        frame.dispose();
+    }
+
+    public bug6406264(Object ... items) {
+        super(items);
+    }
+
+    public void updateUI() {
+        setUI(new CustomComboBoxUI());
+    }
+
+    // Use FocusablePopup for our JComboBox
+    private class CustomComboBoxUI extends BasicComboBoxUI {
+        protected ComboPopup createPopup() {
+            return new FocusablePopup(bug6406264.this);
+        }
+    }
+
+    // Popup window which can take a focus
+    private class FocusablePopup extends BasicComboPopup {
+        public FocusablePopup(JComboBox combo) {
+            super(combo);
+        }
+
+        public boolean isFocusable() {
+            return true;
+        }
+    }
+}
--- a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java	Mon Nov 10 16:37:40 2014 +0300
@@ -41,10 +41,13 @@
  * @bug 8015300
  * @summary Tests that editable combobox select all text
  * @author Sergey Malenkov
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main Test8015300
  */
 
 public class Test8015300 {
-    private static final SunToolkit STK = (SunToolkit) Toolkit.getDefaultToolkit();
+    private static final ExtendedRobot robot = createRobot();
     private static final String[] ITEMS = {
             "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
             "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
@@ -113,7 +116,15 @@
                 combo.setSelectedIndex(index);
             }
         });
-        STK.realSync();
-        Thread.sleep(50L);
+        robot.waitForIdle(50);
+    }
+    private static ExtendedRobot createRobot() {
+         try {
+             ExtendedRobot robot = new ExtendedRobot();
+             return robot;
+         }catch(Exception ex) {
+             ex.printStackTrace();
+             throw new Error("Unexpected Failure");
+         }
     }
 }
--- a/jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -25,6 +25,7 @@
    @bug 8006417
    @summary JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
    @author Anton Litvinov
+   @run main ShowPopupAfterHidePopupTest
 */
 
 import java.awt.*;
@@ -32,8 +33,6 @@
 import javax.swing.*;
 import javax.swing.plaf.metal.*;
 
-import sun.awt.SunToolkit;
-
 public class ShowPopupAfterHidePopupTest {
     private static JFrame frame = null;
     private static JComboBox comboBox = null;
@@ -41,6 +40,7 @@
 
     public static void main(String[] args) throws Exception {
         UIManager.setLookAndFeel(new MetalLookAndFeel());
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
@@ -51,8 +51,7 @@
                 frame.setVisible(true);
             }
         });
-        final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -62,7 +61,7 @@
                 comboBox.showPopup();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
--- a/jdk/test/javax/swing/JComponent/6989617/bug6989617.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JComponent/6989617/bug6989617.java	Mon Nov 10 16:37:40 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug6989617
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 
@@ -38,7 +36,7 @@
     private static JButton button;
 
     public static void main(String... args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 JFrame frame = new JFrame();
@@ -56,14 +54,14 @@
         // Testing the panel as a painting origin,
         // the panel.paintImmediately() must be triggered
         // when button.repaint() is called
-        toolkit.realSync();
+        robot.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 panel.resetPaintRectangle();
                 button.repaint();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 Rectangle pr = panel.getPaintRectangle();
@@ -78,7 +76,7 @@
         // Testing the panel as NOT a painting origin
         // the panel.paintImmediately() must NOT be triggered
         // when button.repaint() is called
-        toolkit.realSync();
+        robot.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 panel.resetPaintRectangle();
@@ -89,7 +87,7 @@
                 button.repaint();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 if(panel.getPaintRectangle() != null) {
--- a/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java	Mon Nov 10 16:37:40 2014 +0300
@@ -25,10 +25,9 @@
  * @bug 4492274
  * @summary  Tests if JEditorPane.getPage() correctly returns anchor reference.
  * @author Denis Sharypov
+ * @run main bug4492274
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.text.html.HTMLEditorKit;
 import java.awt.*;
@@ -42,8 +41,8 @@
     private static JEditorPane jep;
 
     public static void main(String args[]) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
@@ -51,7 +50,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -65,7 +64,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (getPageAnchor() == null) {
             throw new RuntimeException("JEditorPane.getPage() returns null anchor reference");
--- a/jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java	Mon Nov 10 16:37:40 2014 +0300
@@ -24,6 +24,8 @@
    @bug 4251301
    @summary Keybinding for show/hide the system menu.
    @author Andrey Pikalev
+   @library ../../../../lib/testlibrary
+   @build jdk.testlibrary.OSInfo
    @run main/manual bug4251301
 */
 
@@ -32,12 +34,10 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.*;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
 
 
 public class bug4251301 {
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
     static Test test = new Test();
     public static void main(String[] args) throws Exception {
         if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
@@ -50,7 +50,8 @@
                 createAndShowGUI();
             }
         });
-        toolkit.realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
         test.waitTestResult();
     }
 
--- a/jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java	Mon Nov 10 16:37:40 2014 +0300
@@ -26,10 +26,11 @@
  * @summary Checks that iconified internal frame follows
  *          the main frame borders properly.
  * @author Mikhail Lapshin
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main bug6647340
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.beans.PropertyVetoException;
@@ -38,6 +39,7 @@
     private JFrame frame;
     private Point location;
     private JInternalFrame jif;
+    private static ExtendedRobot robot = createRobot();
 
     public static void main(String[] args) throws Exception {
         final bug6647340 test = new bug6647340();
@@ -74,13 +76,13 @@
     }
 
     private void test() throws Exception {
-        realSync();
+        sync();
         test1();
-        realSync();
+        sync();
         check1();
-        realSync();
+        sync();
         test2();
-        realSync();
+        sync();
         check2();
     }
 
@@ -101,14 +103,14 @@
                 setIcon(false);
             }
         });
-        realSync();
+        sync();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 Dimension size = frame.getSize();
                 frame.setSize(size.width - 100, size.height - 100);
             }
         });
-        realSync();
+        sync();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 setIcon(true);
@@ -132,8 +134,17 @@
         }
     }
 
-    private static void realSync() {
-        ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
+    private static void sync() {
+        robot.waitForIdle();
+    }
+    private static ExtendedRobot createRobot() {
+        try {
+             ExtendedRobot robot = new ExtendedRobot();
+             return robot;
+         }catch(Exception ex) {
+             ex.printStackTrace();
+             throw new Error("Unexpected Failure");
+         }
     }
 
     private void setIcon(boolean b) {
--- a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java	Mon Nov 10 16:37:40 2014 +0300
@@ -26,6 +26,9 @@
  * @summary Checks that JInternalFrame's system menu
  *          can be localized during run-time
  * @author Mikhail Lapshin
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main bug6725409
  */
 
 import javax.swing.*;
@@ -36,6 +39,7 @@
     private JInternalFrame iFrame;
     private TestTitlePane testTitlePane;
     private boolean passed;
+    private static ExtendedRobot robot = createRobot();
 
     public static void main(String[] args) throws Exception {
         try {
@@ -53,19 +57,19 @@
                     bug6725409.setupUIStep1();
                 }
             });
-            realSync();
+            sync();
             SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
                     bug6725409.setupUIStep2();
                 }
             });
-            realSync();
+            sync();
             SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
                     bug6725409.test();
                 }
             });
-            realSync();
+            sync();
             bug6725409.checkResult();
         } finally {
             if (bug6725409.frame != null) {
@@ -137,8 +141,17 @@
         }
     }
 
-    private static void realSync() {
-        ((sun.awt.SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
+    private static void sync() {
+        robot.waitForIdle();
+    }
+    private static ExtendedRobot createRobot() {
+        try {
+             ExtendedRobot robot = new ExtendedRobot();
+             return robot;
+         }catch(Exception ex) {
+             ex.printStackTrace();
+             throw new Error("Unexpected Failure");
+         }
     }
 
     // Extend WindowsInternalFrameTitlePane to get access to systemPopupMenu
--- a/jdk/test/javax/swing/JLayer/6824395/bug6824395.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JLayer/6824395/bug6824395.java	Mon Nov 10 16:37:40 2014 +0300
@@ -25,11 +25,12 @@
  * @test
  * @summary Checks that JLayer inside JViewport works is correctly laid out
  * @author Alexander Potochkin
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
  * @run main bug6824395
  */
 
 
-import sun.awt.SunToolkit;
 
 import javax.swing.*;
 import javax.swing.plaf.LayerUI;
@@ -40,7 +41,6 @@
     static JScrollPane scrollPane;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 JFrame frame = new JFrame("testing");
@@ -68,7 +68,13 @@
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        try {
+             ExtendedRobot robot = new ExtendedRobot();
+             robot.waitForIdle(300);
+         }catch(Exception ex) {
+             ex.printStackTrace();
+             throw new Error("Unexpected Failure");
+         }
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6583251/bug6583251.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+@test
+@bug 6583251
+@summary One more ClassCastException in Swing with TrayIcon
+@author Alexander Potochkin
+@run main bug6583251
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+
+public class bug6583251 {
+    private static JFrame frame;
+    private static JPopupMenu menu;
+
+    private static void createGui() {
+        frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JPanel panel = new JPanel();
+        menu = new JPopupMenu();
+        menu.add(new JMenuItem("item"));
+        panel.setComponentPopupMenu(menu);
+        frame.add(panel);
+
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                createGui();
+            }
+        });
+
+        Robot robot = new Robot();
+        robot.waitForIdle();
+        menu.show(frame, 0, 0);
+        robot.waitForIdle();
+
+        TrayIcon trayIcon = new TrayIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB));
+        MouseEvent ev = new MouseEvent(
+                new JButton(), MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, 0, 0, 1, false);
+        ev.setSource(trayIcon);
+        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev);
+    }
+}
--- a/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java	Mon Nov 10 16:37:40 2014 +0300
@@ -31,8 +31,6 @@
  * @run main bug6691503
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 
@@ -93,7 +91,13 @@
     }
 
     private void checkResult() {
-        ((SunToolkit)(Toolkit.getDefaultToolkit())).realSync();
+        try {
+            Robot robot = new Robot();
+            robot.waitForIdle();
+        }catch(Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException("Unexpected failure");
+        }
         if (!isAlwaysOnTop1 || isAlwaysOnTop2) {
             throw new RuntimeException("Malicious applet can show always-on-top " +
                     "popup menu which has whole screen size");
--- a/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Mon Nov 10 16:37:40 2014 +0300
@@ -32,25 +32,25 @@
 
 import javax.swing.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 import java.security.Permission;
-import sun.awt.AWTPermissions;
 
 public class bug6694823 {
     private static JFrame frame;
     private static JPopupMenu popup;
-    private static SunToolkit toolkit;
+    private static Toolkit toolkit;
     private static Insets screenInsets;
+    private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        toolkit = Toolkit.getDefaultToolkit();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 createGui();
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Get screen insets
         screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
@@ -61,12 +61,9 @@
 
         System.setSecurityManager(new SecurityManager(){
 
-            private String allowsAlwaysOnTopPermission =
-                AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName();
-
             @Override
             public void checkPermission(Permission perm) {
-                if (allowsAlwaysOnTopPermission.equals(perm.getName())) {
+                if (perm.getName().equals("setWindowAlwaysOnTop") ) {
                     throw new SecurityException();
                 }
             }
@@ -107,7 +104,7 @@
         });
 
         // Ensure frame is visible
-        toolkit.realSync();
+        robot.waitForIdle();
 
         final Point point = new Point();
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -120,7 +117,7 @@
         });
 
         // Ensure popup is visible
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
--- a/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java	Mon Nov 10 16:37:40 2014 +0300
@@ -33,15 +33,14 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.util.*;
-import sun.awt.SunToolkit;
 
 public class bug4865918 {
 
     private static TestScrollBar sbar;
 
     public static void main(String[] argv) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
 
             public void run() {
@@ -49,7 +48,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -59,7 +58,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         int value = getValue();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JScrollPane/6274267/bug6274267.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 6274267
+   @summary Checks that ScrollPaneLayout properly calculates preferred
+   layout size.
+   @author Mikhail Lapshin
+   @run main bug6274267
+*/
+
+import javax.swing.*;
+import java.awt.*;
+
+public class bug6274267 {
+    private JFrame frame;
+    private Component left;
+
+    public static void main(String[] args) throws Exception {
+        final bug6274267 test = new bug6274267();
+        Robot robot = new Robot();
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    test.setupUI1();
+                }
+            });
+            robot.waitForIdle();
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    test.setupUI2();
+                }
+            });
+            test.test();
+        } finally {
+            if (test.frame != null) {
+                test.frame.dispose();
+            }
+        }
+    }
+
+    private void setupUI1() {
+        frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        left = new JPanel();
+        left.setPreferredSize(new Dimension(100, 100));
+
+        JPanel rightPanel = new JPanel();
+        rightPanel.setPreferredSize(new Dimension(100, 50));
+        Component right = new JScrollPane(rightPanel);
+
+        JSplitPane split =
+                new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
+
+        frame = new JFrame();
+        frame.add(split);
+        frame.pack();
+    }
+
+    // It is important to separate frame.pack() from frame.setVisible(true).
+    // Otherwise the repaint manager will combine validate() calls and
+    // the bug won't appear.
+    private void setupUI2() {
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    private void test() throws Exception {
+        if (left.getSize().width == 100) {
+            System.out.println("Test passed");
+        } else {
+            throw new RuntimeException("ScrollPaneLayout sometimes improperly " +
+                    "calculates the preferred layout size. ");
+        }
+    }
+}
--- a/jdk/test/javax/swing/JSpinner/8008657/bug8008657.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JSpinner/8008657/bug8008657.java	Mon Nov 10 16:37:40 2014 +0300
@@ -22,7 +22,7 @@
  */
 
 import java.awt.ComponentOrientation;
-import java.awt.Toolkit;
+import java.awt.Robot;
 import java.util.Calendar;
 import java.util.Date;
 import javax.swing.JFrame;
@@ -32,7 +32,6 @@
 import javax.swing.SpinnerModel;
 import javax.swing.SpinnerNumberModel;
 import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -43,19 +42,19 @@
  */
 public class bug8008657 {
 
-    private static SunToolkit toolkit;
+    private static Robot robot;
     private static JSpinner spinner;
 
     public static void main(String[] args) throws Exception {
 
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
 
         SwingUtilities.invokeAndWait(() -> {
             createDateSpinner();
             createAndShowUI();
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         testSpinner(false);
 
         SwingUtilities.invokeAndWait(() -> {
@@ -63,7 +62,7 @@
             createAndShowUI();
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         testSpinner(true);
     }
 
@@ -73,7 +72,7 @@
         SwingUtilities.invokeAndWait(() -> {
             spinner.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(() -> {
 
@@ -91,7 +90,7 @@
             spinner.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(() -> {
             JTextField textField = getTextField();
@@ -152,4 +151,4 @@
         frame.getContentPane().add(spinner);
         frame.setVisible(true);
     }
-}
\ No newline at end of file
+}
--- a/jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java	Mon Nov 10 16:37:40 2014 +0300
@@ -30,7 +30,6 @@
 import javax.swing.*;
 import java.awt.*;
 import java.lang.reflect.*;
-import sun.awt.SunToolkit;
 
 
 public class bug4816114 {
@@ -46,14 +45,14 @@
 
     static bug4816114 test = new bug4816114();
 
-    public static void main(String[] args) throws InterruptedException, InvocationTargetException {
+    public static void main(String[] args) throws InterruptedException, InvocationTargetException, AWTException {
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 test.createAndShowGUI();
             }
         });
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
         Thread.sleep(1000);
         Thread.sleep(2000);
 
--- a/jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java	Mon Nov 10 16:37:40 2014 +0300
@@ -22,7 +22,6 @@
  */
 
 import java.awt.BorderLayout;
-import sun.awt.SunToolkit;
 
 import java.awt.Container;
 import java.awt.Rectangle;
@@ -41,7 +40,10 @@
  * @test
  * @bug 7024235
  * @summary Tests JFrame.pack() with the JTabbedPane
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
  * @author Sergey Malenkov
+ * @run main Test7024235
  */
 
 public class Test7024235 implements Runnable {
@@ -50,13 +52,17 @@
 
     public static void main(String[] args) throws Exception {
         Test7024235 test = new Test7024235();
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
             UIManager.setLookAndFeel(info.getClassName());
 
             test.test();
-            toolkit.realSync();
-            Thread.sleep(1000);
+            try {
+                ExtendedRobot robot = new ExtendedRobot();
+                robot.waitForIdle(1000);
+            }catch(Exception ex) {
+                ex.printStackTrace();
+                throw new Error("Unexpected Failure");
+            }
             test.test();
         }
     }
--- a/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java	Mon Nov 10 16:37:40 2014 +0300
@@ -34,13 +34,14 @@
 import javax.swing.UIManager;
 import javax.swing.plaf.metal.MetalLookAndFeel;
 
-import sun.awt.SunToolkit;
 
 /**
  * @test
  * @bug 7170310
  * @author Alexey Ivanov
  * @summary Selected tab should be scrolled into view.
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
  * @run main bug7170310
  */
 public class bug7170310 {
@@ -58,12 +59,11 @@
             UIManager.setLookAndFeel(new MetalLookAndFeel());
             SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);
 
-            SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-            toolkit.realSync();
+            sync();
 
             for (int i = 0; i < TABS_NUMBER; i++) {
                 SwingUtilities.invokeAndWait(bug7170310::addTab);
-                toolkit.realSync();
+                sync();
             }
 
             SwingUtilities.invokeAndWait(bug7170310::check);
@@ -121,4 +121,13 @@
             exception = e;
         }
     }
+    private static void sync() {
+        try {
+             ExtendedRobot robot = new ExtendedRobot();
+             robot.waitForIdle(300);
+         }catch(Exception ex) {
+             ex.printStackTrace();
+             throw new Error("Unexpected Failure");
+         }
+    }
 }
--- a/jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java	Mon Nov 10 16:37:40 2014 +0300
@@ -22,12 +22,12 @@
  */
 import java.awt.BorderLayout;
 import java.awt.Toolkit;
+import java.awt.Robot;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JTabbedPane;
 import javax.swing.SwingUtilities;
 import javax.swing.plaf.metal.MetalLookAndFeel;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -45,6 +45,7 @@
 
     public static void main(String[] args) throws Exception {
 
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(() -> {
             frame = new JFrame();
             frame.setSize(500, 500);
@@ -61,7 +62,7 @@
             frame.setVisible(true);
         });
 
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(() -> {
             for (int j = 0; j < ITERATIONS; j++) {
@@ -70,7 +71,7 @@
                 }
             }
         });
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(() -> frame.dispose());
     }
--- a/jdk/test/javax/swing/JTable/8032874/bug8032874.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JTable/8032874/bug8032874.java	Mon Nov 10 16:37:40 2014 +0300
@@ -37,15 +37,13 @@
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableRowSorter;
 
-import sun.awt.SunToolkit;
-
 public class bug8032874 {
     private static final int ROW_COUNT = 5;
     private static JTable table;
     private static TestTableModel tableModel;
 
     public static void main(String args[]) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -53,7 +51,7 @@
                 createAndShowUI();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -63,7 +61,7 @@
                 table.setRowSelectionInterval(1, 2);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
--- a/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java	Mon Nov 10 16:37:40 2014 +0300
@@ -31,8 +31,6 @@
  * @author Sean Chou
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.text.DefaultCaret;
 import java.awt.*;
@@ -53,7 +51,7 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
@@ -70,7 +68,7 @@
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clipboard = textField.getToolkit().getSystemSelection();
         if (null == clipboard) {
@@ -83,7 +81,7 @@
                 textField.requestFocusInWindow();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -93,7 +91,7 @@
                 caret.moveDot(4);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         String oldSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
         System.out.println("oldSelection is " + oldSelection);
@@ -104,7 +102,7 @@
                 button.requestFocusInWindow();
             }
         });
-        toolkit.realSync(); // So JTextField loses the focus.
+        robot.waitForIdle(); // So JTextField loses the focus.
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -113,7 +111,7 @@
                 caret.moveDot(6);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         String newSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
         System.out.println("newSelection is " + newSelection);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JToolBar/4529206/bug4529206.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug     4529206
+   @summary JToolBar - setFloating does not work correctly
+   @author  Konstantin Eremin
+   @run     main bug4529206
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class bug4529206 extends JFrame {
+    static JFrame frame;
+    static JToolBar jToolBar1;
+    public bug4529206() {
+        setDefaultCloseOperation(EXIT_ON_CLOSE);
+        JPanel jPanFrame = (JPanel) this.getContentPane();
+        jPanFrame.setLayout(new BorderLayout());
+        this.setSize(new Dimension(200, 100));
+        this.setLocation(125, 75);
+        this.setTitle("Test Floating Toolbar");
+        jToolBar1 = new JToolBar();
+        JButton jButton1 = new JButton("Float");
+        jPanFrame.add(jToolBar1, BorderLayout.NORTH);
+        JTextField tf = new JTextField("click here");
+        jPanFrame.add(tf);
+        jToolBar1.add(jButton1, null);
+        jButton1.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                buttonPressed(e);
+            }
+        });
+        makeToolbarFloat();
+        setVisible(true);
+    }
+
+    private void makeToolbarFloat() {
+        javax.swing.plaf.basic.BasicToolBarUI ui = (javax.swing.plaf.basic.BasicToolBarUI) jToolBar1.getUI();
+        if (!ui.isFloating()) {
+            ui.setFloatingLocation(100, 100);
+            ui.setFloating(true, jToolBar1.getLocation());
+        }
+    }
+
+    private void buttonPressed(ActionEvent e) {
+        makeToolbarFloat();
+    }
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame = new bug4529206();
+            }
+        });
+        Robot robot = new Robot();
+        robot.waitForIdle();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                if (frame.isFocused()) {
+                    throw (new RuntimeException("setFloating does not work correctly"));
+                }
+            }
+        });
+    }
+}
--- a/jdk/test/javax/swing/JViewport/7107099/bug7107099.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/JViewport/7107099/bug7107099.java	Mon Nov 10 16:37:40 2014 +0300
@@ -27,8 +27,6 @@
    @author Pavel Porvatov
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 
@@ -43,7 +41,8 @@
     private static int extent;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        java.awt.Robot robot = new java.awt.Robot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -61,7 +60,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -81,7 +80,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/Popup/6514582/bug6514582.java	Mon Nov 10 16:37:40 2014 +0300
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 6514582
+   @summary SubMenu of a JMenu with no items paints a single pixel tiny menu.
+   @author Alexander Potochkin
+   @run main bug6514582
+*/
+
+import javax.swing.*;
+import java.awt.*;
+
+public class bug6514582 {
+    private static JPopupMenu popup;
+
+    public static void main(String ...args) throws Exception {
+        Robot robot = new Robot();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                popup = new JPopupMenu();
+                popup.add(new JMenuItem("item"));
+                popup.setVisible(true);
+
+            }
+        });
+
+        robot.waitForIdle();
+
+        if (!popup.isShowing()) {
+            throw new RuntimeException("Where is my popup ?");
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                popup.setVisible(false);
+                popup.removeAll();
+                popup.setVisible(true);
+            }
+        });
+
+        robot.waitForIdle();
+
+        if (popup.isShowing()) {
+            throw new RuntimeException("Empty popup is shown");
+        }
+
+        popup.setVisible(false);
+    }
+}
--- a/jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -31,7 +31,6 @@
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import sun.awt.*;
 
 public class IconifyTest {
     private static volatile boolean windowIconifiedIsCalled = false;
@@ -40,7 +39,7 @@
     static JButton button;
 
     public static void main(String[] args) throws Throwable {
-        SunToolkit toolkit = (SunToolkit) SunToolkit.getDefaultToolkit();
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame = new JFrame();
@@ -61,14 +60,14 @@
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.setExtendedState(Frame.ICONIFIED);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!windowIconifiedIsCalled) {
             throw new Exception("Test failed: window was not iconified.");
--- a/jdk/test/javax/swing/Security/6657138/ComponentTest.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/Security/6657138/ComponentTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -28,8 +28,6 @@
  * @author Alexander Potochkin
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 
@@ -50,14 +48,14 @@
 
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame = new ComponentTest();
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
         for (final UIManager.LookAndFeelInfo laf : lafs) {
             SwingUtilities.invokeAndWait(new Runnable() {
@@ -70,7 +68,7 @@
                     SwingUtilities.updateComponentTreeUI(frame);
                 }
             });
-            toolkit.realSync();
+            robot.waitForIdle();
         }
     }
 }
--- a/jdk/test/javax/swing/SwingTest.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/SwingTest.java	Mon Nov 10 16:37:40 2014 +0300
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import sun.awt.SunToolkit;
 import java.awt.Toolkit;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -134,11 +133,8 @@
             else {
                 SwingUtilities.invokeLater(this); // invoke on the event dispatch thread
             }
-            Toolkit tk = Toolkit.getDefaultToolkit();
-            if (tk instanceof SunToolkit) {
-                SunToolkit stk = (SunToolkit) tk;
-                stk.realSync(); // wait until done
-            }
+            java.awt.Robot robot = new java.awt.Robot();
+            robot.waitForIdle();
         }
         while (this.frame != null);
         if (this.error != null) {
--- a/jdk/test/javax/swing/text/Utilities/bug7045593.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/text/Utilities/bug7045593.java	Mon Nov 10 16:37:40 2014 +0300
@@ -28,8 +28,6 @@
  * @author Pavel Porvatov
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.text.BadLocationException;
 import java.awt.*;
@@ -49,7 +47,8 @@
             }
         });
 
-        ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/jdk/test/javax/swing/text/View/8048110/bug8048110.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/text/View/8048110/bug8048110.java	Mon Nov 10 16:37:40 2014 +0300
@@ -28,8 +28,6 @@
  * @run main bug8048110
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.text.Element;
 import javax.swing.text.html.HTMLDocument;
@@ -37,7 +35,7 @@
 import java.awt.*;
 
 public class bug8048110 {
-    private static SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
+    private static Robot robot;
     private static Object lock = new Object();
     private static boolean isRealSyncPerformed = false;
     private static final String htmlText = "<table width=\"100%\" cellpadding=\"10\" cellspacing=\"5\" align=\"center\">" +
@@ -45,6 +43,7 @@
             "<tr><td align=\"left\" bgcolor=\"#bec3c6\">PC</td><td align=\"left\" bgcolor=\"#46a055\">Ok</td></tr></table>";
 
     public static void main(String[] args) throws Exception {
+        robot = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
@@ -55,7 +54,7 @@
         Thread thread = new Thread() {
             @Override
             public void run() {
-                toolkit.realSync();
+                robot.waitForIdle();
                 synchronized (lock) {
                     isRealSyncPerformed = true;
                     lock.notifyAll();
--- a/jdk/test/javax/swing/text/html/7189299/bug7189299.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/text/html/7189299/bug7189299.java	Mon Nov 10 16:37:40 2014 +0300
@@ -25,7 +25,7 @@
  * Portions Copyright (c) 2013 IBM Corporation
  */
 import java.awt.BorderLayout;
-import java.awt.Toolkit;
+import java.awt.Robot;
 
 import java.awt.event.ActionListener;
 import javax.swing.DefaultButtonModel;
@@ -35,7 +35,6 @@
 import javax.swing.text.StyleConstants;
 import javax.swing.text.StyleContext;
 import javax.swing.text.html.HTMLEditorKit;
-import sun.awt.SunToolkit;
 
 
 /*
@@ -111,7 +110,7 @@
     }
 
     public static void main(String[] args) throws Exception {
-        final SunToolkit toolkit = ((SunToolkit) Toolkit.getDefaultToolkit());
+        final Robot robot = new Robot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -120,7 +119,7 @@
                 setup();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable() {
 
             @Override
--- a/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java	Mon Nov 10 16:37:40 2014 +0300
@@ -28,8 +28,6 @@
  * @run main bug8058120
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.text.Element;
 import javax.swing.text.html.HTML;
@@ -38,12 +36,18 @@
 import java.awt.*;
 
 public class bug8058120 {
-    private static SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
     private static HTMLDocument document = null;
     private static final String text = "<p id = 'ab'>ab</p>";
     private static final String textToInsert = "c";
 
     public static void main(String[] args) {
+        Robot robot;
+        try {
+             robot = new Robot();
+        }catch(Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException("Unexpected failure");
+        }
         SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
@@ -51,7 +55,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeLater(new Runnable() {
             @Override
@@ -64,7 +68,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeLater(new Runnable() {
             @Override
--- a/jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java	Mon Nov 10 16:37:40 2014 +0300
@@ -27,8 +27,6 @@
    @author Peter Zhelezniakov
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -85,7 +83,8 @@
             }
         });
 
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
--- a/jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java	Mon Nov 10 16:23:30 2014 +0300
+++ b/jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java	Mon Nov 10 16:37:40 2014 +0300
@@ -28,9 +28,8 @@
    @run main bug7165725
 */
 
-import sun.awt.SunToolkit;
-
 import java.awt.BorderLayout;
+import java.awt.Robot;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
@@ -127,7 +126,8 @@
             }
         });
 
-        ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {