changeset 14863:c7c0c3c9f33c

8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2 8064573: [TEST_BUG] javax/swing/text/AbstractDocument/6968363/Test6968363.java is asocial pressing VK_LEFT and not releasing 8064575: [TEST_BUG] javax/swing/JEditorPane/6917744/bug6917744.java 100 times press keys and never releases 8064809: [TEST_BUG] javax/swing/JComboBox/4199622/bug4199622.java contains a lot of keyPress and not a single keyRelease Reviewed-by: alexsch, pchelko
author yan
date Fri, 21 Nov 2014 16:11:03 +0300
parents 93c777477e2c
children 3b4fb96700f5
files test/javax/swing/AbstractButton/6711682/bug6711682.java test/javax/swing/JButton/4368790/bug4368790.java test/javax/swing/JColorChooser/Test6541987.java test/javax/swing/JColorChooser/Test6827032.java test/javax/swing/JColorChooser/Test7194184.java test/javax/swing/JComboBox/4199622/bug4199622.java test/javax/swing/JComboBox/4515752/DefaultButtonTest.java test/javax/swing/JComboBox/4743225/bug4743225.java test/javax/swing/JComboBox/6236162/bug6236162.java test/javax/swing/JComboBox/6559152/bug6559152.java test/javax/swing/JComboBox/6607130/bug6607130.java test/javax/swing/JComboBox/8032878/bug8032878.java test/javax/swing/JComboBox/8057893/bug8057893.java test/javax/swing/JComponent/6683775/bug6683775.java test/javax/swing/JComponent/7154030/bug7154030.java test/javax/swing/JEditorPane/6917744/bug6917744.java test/javax/swing/JFileChooser/4524490/bug4524490.java test/javax/swing/JFileChooser/7199708/bug7199708.java test/javax/swing/JFileChooser/8002077/bug8002077.java test/javax/swing/JFileChooser/8021253/bug8021253.java test/javax/swing/JFrame/4962534/bug4962534.java test/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java test/javax/swing/JInternalFrame/5066752/bug5066752.java test/javax/swing/JInternalFrame/8020708/bug8020708.java test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java test/javax/swing/JList/6462008/bug6462008.java test/javax/swing/JList/6510999/bug6510999.java test/javax/swing/JMenu/4417601/bug4417601.java test/javax/swing/JMenu/4515762/bug4515762.java test/javax/swing/JMenu/4692443/bug4692443.java test/javax/swing/JMenu/6359669/bug6359669.java test/javax/swing/JMenu/6470128/bug6470128.java test/javax/swing/JMenu/6538132/bug6538132.java test/javax/swing/JMenuBar/4750590/bug4750590.java test/javax/swing/JMenuItem/4171437/bug4171437.java test/javax/swing/JMenuItem/4654927/bug4654927.java test/javax/swing/JMenuItem/6209975/bug6209975.java test/javax/swing/JMenuItem/6249972/bug6249972.java test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java test/javax/swing/JOptionPane/6428694/bug6428694.java test/javax/swing/JOptionPane/7138665/bug7138665.java test/javax/swing/JPopupMenu/4458079/bug4458079.java test/javax/swing/JPopupMenu/4634626/bug4634626.html test/javax/swing/JPopupMenu/4634626/bug4634626.java test/javax/swing/JPopupMenu/4966112/bug4966112.java test/javax/swing/JPopupMenu/6217905/bug6217905.java test/javax/swing/JPopupMenu/6415145/bug6415145.java test/javax/swing/JPopupMenu/6515446/bug6515446.java test/javax/swing/JPopupMenu/6544309/bug6544309.java test/javax/swing/JPopupMenu/6580930/bug6580930.java test/javax/swing/JPopupMenu/6800513/bug6800513.java test/javax/swing/JPopupMenu/6827786/bug6827786.java test/javax/swing/JPopupMenu/6987844/bug6987844.java test/javax/swing/JPopupMenu/7154841/bug7154841.java test/javax/swing/JRadioButton/8033699/bug8033699.java test/javax/swing/JRootPane/4670486/bug4670486.java test/javax/swing/JScrollBar/4708809/bug4708809.java test/javax/swing/JScrollBar/6542335/bug6542335.java test/javax/swing/JScrollBar/7163696/Test7163696.java test/javax/swing/JScrollBar/bug4202954/bug4202954.java test/javax/swing/JSlider/6348946/bug6348946.java test/javax/swing/JSlider/6401380/bug6401380.java test/javax/swing/JSlider/6848475/bug6848475.java test/javax/swing/JSpinner/4973721/bug4973721.java test/javax/swing/JSpinner/5012888/bug5012888.java test/javax/swing/JSplitPane/4885629/bug4885629.java test/javax/swing/JTabbedPane/4361477/bug4361477.java test/javax/swing/JTabbedPane/4624207/bug4624207.java test/javax/swing/JTabbedPane/6495408/bug6495408.java test/javax/swing/JTabbedPane/7161568/bug7161568.java test/javax/swing/JTable/4220171/bug4220171.java test/javax/swing/JTable/6263446/bug6263446.java test/javax/swing/JTable/6777378/bug6777378.java test/javax/swing/JTable/7055065/bug7055065.java test/javax/swing/JTable/7068740/bug7068740.java test/javax/swing/JTableHeader/6884066/bug6884066.java test/javax/swing/JTableHeader/6889007/bug6889007.java test/javax/swing/JTextArea/4697612/bug4697612.java test/javax/swing/JTextField/8036819/bug8036819.java test/javax/swing/JToolBar/4247996/bug4247996.java test/javax/swing/JToolTip/4846413/bug4846413.java test/javax/swing/JTree/4330357/bug4330357.java test/javax/swing/JTree/4908142/bug4908142.java test/javax/swing/JTree/4927934/bug4927934.java test/javax/swing/JTree/6263446/bug6263446.java test/javax/swing/JTree/6505523/bug6505523.java test/javax/swing/JTree/6578666/bug6578666.java test/javax/swing/JTree/8003400/Test8003400.java test/javax/swing/JTree/8004298/bug8004298.java test/javax/swing/Popup/TaskbarPositionTest.java test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java test/javax/swing/SwingUtilities/4917669/bug4917669.java test/javax/swing/SwingUtilities/7146377/bug7146377.java test/javax/swing/ToolTipManager/Test6256140.java test/javax/swing/dnd/7171812/bug7171812.java test/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java test/javax/swing/plaf/basic/BasicMenuUI/4983388/bug4983388.java test/javax/swing/plaf/basic/BasicTreeUI/8023474/bug8023474.java test/javax/swing/plaf/synth/7158712/bug7158712.java test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java test/javax/swing/plaf/windows/WindowsRootPaneUI/WrongAltProcessing/WrongAltProcessing.java test/javax/swing/text/AbstractDocument/6968363/Test6968363.java test/javax/swing/text/CSSBorder/6796710/bug6796710.java test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java test/javax/swing/text/JTextComponent/5074573/bug5074573.java test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java test/javax/swing/text/View/8014863/bug8014863.java test/javax/swing/text/html/CSS/4530474/bug4530474.java test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java
diffstat 109 files changed, 2418 insertions(+), 621 deletions(-) [+]
line wrap: on
line diff
--- a/test/javax/swing/AbstractButton/6711682/bug6711682.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/AbstractButton/6711682/bug6711682.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug6711682
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.event.CellEditorListener;
 import javax.swing.table.TableCellEditor;
@@ -47,13 +45,12 @@
     public static void main(String[] args) throws Exception {
         Robot robot = new Robot();
         robot.setAutoDelay(50);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 createAndShowGUI();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         Point l = table.getLocationOnScreen();
         int h = table.getRowHeight();
         for (int i = 0; i < 3; i++) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JButton/4368790/bug4368790.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2010, 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.
+ *
+ * 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 4368790
+   @summary JButton stays pressed when focus stolen
+   @author Alexander Potochkin
+   @run main bug4368790
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug4368790 {
+    private static JButton b1;
+
+    private static void createGui() {
+        final JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setLayout(new FlowLayout());
+
+        b1 = new JButton("Button1");
+        frame.add(b1);
+        frame.add(new JButton("Button2"));
+
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+        b1.requestFocus();
+    }
+
+    public static void main(String[] args) throws Exception {
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                bug4368790.createGui();
+            }
+        });
+        robot.waitForIdle();
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.waitForIdle();
+        if (b1.getModel().isPressed()) {
+            throw new RuntimeException("The button is unexpectedly pressed");
+        }
+    }
+}
--- a/test/javax/swing/JColorChooser/Test6541987.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JColorChooser/Test6541987.java	Fri Nov 21 16:11:03 2014 +0300
@@ -39,10 +39,7 @@
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
 
-import sun.awt.SunToolkit;
-
 public class Test6541987 implements Runnable {
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
     private static Robot robot;
 
     public static void main(String[] args) throws AWTException {
@@ -50,14 +47,14 @@
         // test escape after selection
         start();
         click(KeyEvent.VK_ESCAPE);
-        toolkit.realSync();
+        robot.waitForIdle();
         // test double escape after editing
         start();
         click(KeyEvent.VK_1);
         click(KeyEvent.VK_0);
         click(KeyEvent.VK_ESCAPE);
         click(KeyEvent.VK_ESCAPE);
-        toolkit.realSync();
+        robot.waitForIdle();
         // all windows should be closed
         for (Window window : Window.getWindows()) {
             if (window.isVisible()) {
@@ -76,7 +73,7 @@
     }
 
     private static void click(int...keys) {
-        toolkit.realSync();
+        robot.waitForIdle();
         for (int key : keys) {
             robot.keyPress(key);
         }
--- a/test/javax/swing/JColorChooser/Test6827032.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JColorChooser/Test6827032.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,8 +29,6 @@
  * @library ../regtesthelpers
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.event.*;
 
@@ -49,7 +47,6 @@
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -57,7 +54,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/JColorChooser/Test7194184.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JColorChooser/Test7194184.java	Fri Nov 21 16:11:03 2014 +0300
@@ -39,7 +39,6 @@
 import java.awt.AWTException;
 import java.awt.Color;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 
 import javax.swing.JColorChooser;
@@ -47,7 +46,6 @@
 import javax.swing.SwingUtilities;
 
 import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
 
 public class Test7194184 implements Runnable {
     private static JFrame frame;
@@ -60,10 +58,9 @@
 
     private static void testKeyBoardAccess() throws Exception {
         Robot robot = new Robot();
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeLater(new Test7194184());
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeLater(new Runnable() {
             @Override
@@ -78,7 +75,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Tab to move the focus to MainSwatch
         Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
@@ -87,7 +84,7 @@
         Util.hitKeys(robot, KeyEvent.VK_RIGHT);
         Util.hitKeys(robot, KeyEvent.VK_RIGHT);
         Util.hitKeys(robot, KeyEvent.VK_SPACE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
--- a/test/javax/swing/JComboBox/4199622/bug4199622.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComboBox/4199622/bug4199622.java	Fri Nov 21 16:11:03 2014 +0300
@@ -25,12 +25,13 @@
    @bug 4199622
    @summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
    @author Vladislav Karnaukhov
+   @library ../../../../lib/testlibrary
+   @build jdk.testlibrary.OSInfo
    @run main bug4199622
 */
 
 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
 
 import javax.swing.*;
 import javax.swing.plaf.metal.MetalLookAndFeel;
@@ -74,7 +75,6 @@
     }
 
     static Robot robot = null;
-    static SunToolkit toolkit = null;
 
     static void doTest() {
         if (robot == null) {
@@ -86,11 +86,7 @@
             }
         }
 
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        if (toolkit == null) {
-            throw new RuntimeException("Can't get the toolkit. Test failed");
-        }
-        toolkit.realSync();
+        robot.waitForIdle();
 
         doActualTest();
 
@@ -109,7 +105,7 @@
             throw new RuntimeException("Test failed", e);
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
         doActualTest();
     }
 
@@ -144,12 +140,14 @@
         } catch (InvocationTargetException e) {
             throw new RuntimeException("Test failed", e);
         }
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(KeyEvent.VK_END);
-        toolkit.realSync();
+        robot.keyRelease(KeyEvent.VK_END);
+        robot.waitForIdle();
         robot.keyPress(KeyEvent.VK_HOME);
-        toolkit.realSync();
+        robot.keyRelease(KeyEvent.VK_HOME);
+        robot.waitForIdle();
     }
 
     static void doTestUpDown() {
@@ -166,16 +164,18 @@
         } catch (InvocationTargetException e) {
             throw new RuntimeException("Test failed", e);
         }
-        toolkit.realSync();
+        robot.waitForIdle();
 
         for (int i = 0; i < nElems; i++) {
             robot.keyPress(KeyEvent.VK_DOWN);
-            toolkit.realSync();
+            robot.keyRelease(KeyEvent.VK_DOWN);
+            robot.waitForIdle();
         }
 
         for (int i = 0; i < nElems; i++) {
             robot.keyPress(KeyEvent.VK_UP);
-            toolkit.realSync();
+            robot.keyRelease(KeyEvent.VK_UP);
+            robot.waitForIdle();
         }
     }
 
@@ -193,17 +193,19 @@
         } catch (InvocationTargetException e) {
             throw new RuntimeException("Test failed", e);
         }
-        toolkit.realSync();
+        robot.waitForIdle();
 
         int listHeight = cb.getMaximumRowCount();
         for (int i = 0; i < nElems; i += listHeight) {
             robot.keyPress(KeyEvent.VK_PAGE_DOWN);
-            toolkit.realSync();
+            robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
+            robot.waitForIdle();
         }
 
         for (int i = 0; i < nElems; i += listHeight) {
             robot.keyPress(KeyEvent.VK_PAGE_UP);
-            toolkit.realSync();
+            robot.keyRelease(KeyEvent.VK_PAGE_UP);
+            robot.waitForIdle();
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JComboBox/4515752/DefaultButtonTest.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2002, 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.
+ *
+ * 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.
+ */
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+/**
+ * @test
+ * @bug 4515752 4337071
+ * @author Mark Davidson
+ * @summary Tests the invocation of the default button within the JComboBox.
+ */
+public class DefaultButtonTest extends JFrame implements ActionListener {
+
+    private static boolean defaultButtonPressed = false;
+    private static boolean editChanged = false;
+
+    private static String[] strData =  {
+        "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+    };
+
+    private static String[] strData2 =  {
+        "One", "Two", "Three", "Four", "Five", "Six", "Seven"
+    };
+
+    public static void main(String[] args) throws Throwable {
+        SwingUtilities.invokeAndWait(new Runnable(){
+            public void run() {
+                new DefaultButtonTest();
+            }
+        });
+        test();
+        System.out.println("Test Passed");
+    }
+
+    public DefaultButtonTest() {
+        getContentPane().add(new DefaultPanel(this));
+        pack();
+        setVisible(true);
+    }
+
+    public static void test() {
+        // Use Robot to automate the test
+        Robot robot = null;
+        try {
+            robot = new Robot();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        robot.setAutoDelay(125);
+
+        for (int i = 0; i < 3; i++) {
+            // Test ENTER press on the non editable combo.
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            testDefaultButton(true);
+
+            // Test the ENTER press on the editable combo box
+            robot.keyPress(KeyEvent.VK_TAB);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_TAB);
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            testDefaultButton(true);
+
+            // Change the value, should generate a change but not a Default Button press.
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_D);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_D);
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            testEditChange(true);
+            robot.waitForIdle();
+            testDefaultButton(true);
+
+            // Change value, changing focus should fire an ActionEvent.
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_BACK_SPACE);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_SHIFT);
+            robot.waitForIdle();
+            robot.keyPress(KeyEvent.VK_TAB);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_SHIFT);
+            robot.waitForIdle();
+            robot.keyRelease(KeyEvent.VK_TAB);
+            robot.waitForIdle();
+            testEditChange(true);
+            robot.waitForIdle();
+            testDefaultButton(false);
+        }
+    }
+
+    public void actionPerformed(ActionEvent evt) {
+        String cmd = evt.getActionCommand();
+        System.out.println("ActionEvent: " + cmd);
+
+        if (cmd.equals("OK")) {
+            defaultButtonPressed = true;
+        }
+
+        if (cmd.equals("comboBoxChanged")) {
+            editChanged = true;
+        }
+    }
+
+    public static void testDefaultButton(boolean flag) {
+        if (defaultButtonPressed != flag) {
+            new RuntimeException("defaultButtonPressed unexpectedly = " + defaultButtonPressed);
+        }
+        // reset
+        defaultButtonPressed = false;
+    }
+
+    public static void testEditChange(boolean flag) {
+        if (editChanged != flag) {
+            new RuntimeException("editChanged unexpectedly = " + editChanged);
+        }
+        // reset
+        editChanged = false;
+    }
+
+    class DefaultPanel extends JPanel {
+
+        public JComboBox combo;
+        public JComboBox combo2;
+
+        private JButton okButton = new JButton("OK");
+        private JButton cancelButton = new JButton("Cancel");
+
+        public DefaultPanel(JFrame root) {
+            setLayout(new BorderLayout());
+            add(createPanel(), BorderLayout.NORTH);
+            add(createInfoPanel(), BorderLayout.CENTER);
+            add(createButtonPanel(root), BorderLayout.SOUTH);
+        }
+
+        private JPanel createPanel() {
+            combo = new JComboBox(strData);
+            combo.addActionListener(DefaultButtonTest.this);
+            combo2 = new JComboBox(strData2);
+            combo2.setEditable(true);
+            combo2.addActionListener(DefaultButtonTest.this);
+
+            JPanel panel = new JPanel();
+
+            panel.add(combo);
+            panel.add(combo2);
+
+            return panel;
+        }
+
+        private JScrollPane createInfoPanel() {
+            StringBuffer txt = new StringBuffer("Test for 4337071:\n");
+            txt.append("ENTER pressed in NON-EDITABLE combo box should be passed to the OK button.\n");
+            txt.append("For an EDITABLE combo box, the combo box should fire an action event.");
+            txt.append("\n\nTest for 4515752:\n");
+            txt.append("ENTER on an EDITABLE combo box in which the contents has not changed\n");
+            txt.append("should be passed to the default button");
+
+            JTextArea text = new JTextArea(txt.toString());
+            text.setEditable(false);
+
+            return new JScrollPane(text);
+        }
+
+
+        private JPanel createButtonPanel(JFrame frame) {
+            frame.getRootPane().setDefaultButton(okButton);
+
+            // This is just to check when the OK Button was pressed.
+            okButton.addActionListener(DefaultButtonTest.this);
+
+            JPanel panel = new JPanel();
+            panel.add(okButton);
+            panel.add(cancelButton);
+            return panel;
+        }
+    }
+
+}
--- a/test/javax/swing/JComboBox/4743225/bug4743225.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComboBox/4743225/bug4743225.java	Fri Nov 21 16:11:03 2014 +0300
@@ -27,8 +27,6 @@
  * @author Alexander Potochkin
  */
 
-import sun.awt.SunToolkit;
-
 import javax.accessibility.AccessibleContext;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
@@ -39,7 +37,6 @@
 import java.awt.FlowLayout;
 import java.awt.Point;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.InputEvent;
 
 public class bug4743225 extends JFrame {
@@ -80,21 +77,20 @@
 
         Robot robot = new Robot();
         robot.setAutoDelay(20);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 new bug4743225().setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // calling this method from main thread is ok
         Point point = cb.getLocationOnScreen();
         robot.mouseMove(point.x + 10, point.y + 10);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/JComboBox/6236162/bug6236162.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComboBox/6236162/bug6236162.java	Fri Nov 21 16:11:03 2014 +0300
@@ -31,8 +31,6 @@
    @run main bug6236162
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.basic.*;
 import javax.swing.plaf.metal.MetalComboBoxUI;
@@ -40,7 +38,6 @@
 import java.awt.event.KeyEvent;
 
 public class bug6236162 {
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
     private static JFrame frame;
     private static JComboBox combo;
     private static MyComboUI comboUI;
@@ -52,7 +49,6 @@
                 createAndShowGUI();
             }
         });
-        toolkit.realSync();
         test();
         System.out.println("Test passed");
     }
@@ -78,11 +74,11 @@
         robot.setAutoDelay(50);
 
         // Open popup menu
-        realSync();
+        robot.waitForIdle();
         Util.hitKeys(robot, KeyEvent.VK_DOWN);
 
         // Move mouse to the first popup menu item
-        realSync();
+        robot.waitForIdle();
         Point p = combo.getLocationOnScreen();
         Dimension size = combo.getSize();
         p.x += size.width / 2;
@@ -94,10 +90,10 @@
         }
 
         // Select the second popup menu item
-        realSync();
+        robot.waitForIdle();
         Util.hitKeys(robot, KeyEvent.VK_DOWN);
 
-        realSync();
+        robot.waitForIdle();
         JList list = comboUI.getComboPopup().getList();
         if (list.getSelectedIndex() != 1) {
             throw new RuntimeException("There is an inconsistence in combo box " +
@@ -106,9 +102,6 @@
         }
     }
 
-    private static void realSync() {
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
-    }
 
     // Gives access to BasicComboBoxUI.popup field
     private static class MyComboUI extends MetalComboBoxUI {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JComboBox/6559152/bug6559152.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ *
+ * 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 6559152
+   @summary Checks that you can select an item in JComboBox with keyboard
+            when it is a JTable cell editor.
+   @author Mikhail Lapshin
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @run main bug6559152
+*/
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug6559152 {
+    private JFrame frame;
+    private JComboBox cb;
+    private ExtendedRobot robot;
+
+    public static void main(String[] args) throws Exception {
+        final bug6559152 test = new bug6559152();
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    test.setupUI();
+                }
+            });
+            test.test();
+        } finally {
+            if (test.frame != null) {
+                test.frame.dispose();
+            }
+        }
+    }
+
+    private void setupUI() {
+        frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        DefaultTableModel model = new DefaultTableModel(1, 1);
+        JTable table = new JTable(model);
+
+        cb = new JComboBox(new String[]{"one", "two", "three"});
+        cb.setEditable(true);
+        table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(cb));
+        frame.add(cb);
+
+        frame.pack();
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    private void test() throws Exception {
+        robot = new ExtendedRobot();
+        robot.waitForIdle();
+        testImpl();
+        robot.waitForIdle();
+        checkResult();
+    }
+
+    private void testImpl() throws Exception {
+        robot.type(KeyEvent.VK_DOWN);
+        robot.waitForIdle();
+        robot.type(KeyEvent.VK_DOWN);
+        robot.waitForIdle();
+        robot.type(KeyEvent.VK_ENTER);
+    }
+
+    private void checkResult() {
+        if (cb.getSelectedItem().equals("two")) {
+            System.out.println("Test passed");
+        } else {
+            System.out.println("Test failed");
+            throw new RuntimeException("Cannot select an item " +
+                    "from popup with the ENTER key.");
+        }
+    }
+}
--- a/test/javax/swing/JComboBox/6607130/bug6607130.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComboBox/6607130/bug6607130.java	Fri Nov 21 16:11:03 2014 +0300
@@ -30,8 +30,6 @@
  * @author Mikhail Lapshin
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.table.DefaultTableModel;
 import java.awt.*;
@@ -79,44 +77,44 @@
     }
 
     private void test() throws Exception {
-        realSync();
+        robot.waitForIdle();
         test1();
-        realSync();
+        robot.waitForIdle();
         checkResult("First test");
         test2();
-        realSync();
+        robot.waitForIdle();
         checkResult("Second test");
     }
 
     private void test1() throws Exception {
         // Select 'one'
         hitKey(KeyEvent.VK_TAB);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_F2);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_DOWN);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_DOWN);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_ENTER);
-        realSync();
+        robot.waitForIdle();
 
         // Select 'one' again
         hitKey(KeyEvent.VK_F2);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_DOWN);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_ENTER);
-        realSync();
+        robot.waitForIdle();
     }
 
     private void test2() throws Exception {
         // Press F2 and then press ENTER
         // Editor should be shown and then closed
         hitKey(KeyEvent.VK_F2);
-        realSync();
+        robot.waitForIdle();
         hitKey(KeyEvent.VK_ENTER);
-        realSync();
+        robot.waitForIdle();
     }
 
     private void checkResult(String testName) {
@@ -129,10 +127,6 @@
         }
     }
 
-    private static void realSync() {
-        ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
-    }
-
     public void hitKey(int keycode) {
         robot.keyPress(keycode);
         robot.keyRelease(keycode);
--- a/test/javax/swing/JComboBox/8032878/bug8032878.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComboBox/8032878/bug8032878.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,6 +29,7 @@
  * @library ../../regtesthelpers
  * @build Util
  * @author Alexey Ivanov
+ * @run main bug8032878
  */
 
 import java.awt.*;
@@ -36,8 +37,6 @@
 import javax.swing.*;
 import javax.swing.text.JTextComponent;
 
-import sun.awt.SunToolkit;
-
 public class bug8032878 implements Runnable {
     private static final String ONE = "one";
     private static final String TWO = "two";
@@ -99,15 +98,15 @@
     }
 
     private void runTest() throws Exception {
-        realSync();
+        robot.waitForIdle();
         // Select 'one'
         Util.hitKeys(robot, KeyEvent.VK_TAB);
-        realSync();
+        robot.waitForIdle();
         Util.hitKeys(robot, KeyEvent.VK_1);
         Util.hitKeys(robot, KeyEvent.VK_2);
         Util.hitKeys(robot, KeyEvent.VK_3);
         Util.hitKeys(robot, KeyEvent.VK_ENTER);
-        realSync();
+        robot.waitForIdle();
     }
 
     private void checkResult() throws Exception {
@@ -125,9 +124,6 @@
         }
     }
 
-    private static void realSync() {
-        ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
-    }
 
     @Override
     public void run() {
--- a/test/javax/swing/JComboBox/8057893/bug8057893.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComboBox/8057893/bug8057893.java	Fri Nov 21 16:11:03 2014 +0300
@@ -30,7 +30,6 @@
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
 import javax.swing.WindowConstants;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -47,7 +46,6 @@
     public static void main(String[] args) throws Exception {
         Robot robot = new Robot();
         robot.setAutoDelay(50);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         EventQueue.invokeAndWait(() -> {
             JFrame frame = new JFrame();
@@ -69,13 +67,13 @@
             comboBox.requestFocusInWindow();
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(KeyEvent.VK_A);
         robot.keyRelease(KeyEvent.VK_A);
         robot.keyPress(KeyEvent.VK_ENTER);
         robot.keyRelease(KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if(!isComboBoxEdited){
             throw new RuntimeException("ComboBoxEdited event is not fired!");
--- a/test/javax/swing/JComponent/6683775/bug6683775.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComponent/6683775/bug6683775.java	Fri Nov 21 16:11:03 2014 +0300
@@ -38,8 +38,8 @@
 public class bug6683775 {
     public static void main(String[] args) throws Exception {
         GraphicsConfiguration gc = getGC();
-        if (!AWTUtilities.isTranslucencySupported(
-                AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
+       if (!AWTUtilities.isTranslucencySupported(
+               AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
                 || gc == null) {
             return;
         }
--- a/test/javax/swing/JComponent/7154030/bug7154030.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JComponent/7154030/bug7154030.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,7 +29,6 @@
 import javax.swing.JDesktopPane;
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
 
 import java.awt.AWTException;
 import java.awt.AlphaComposite;
@@ -46,7 +45,9 @@
  * @summary Swing components fail to hide after calling hide()
  * @author Jonathan Lu
  * @library ../../regtesthelpers/
+ * @library ../../../../lib/testlibrary/
  * @build Util
+ * @build ExtendedRobot
  * @run main bug7154030
  */
 
@@ -61,9 +62,7 @@
 
         BufferedImage imageHide = null;
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-
-        Robot robot = new Robot();
+        ExtendedRobot robot = new ExtendedRobot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -89,7 +88,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle(500);
         imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -100,13 +99,13 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle(500);
         imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
         if (Util.compareBufferedImages(imageInit, imageShow)) {
             throw new Exception("Failed to show opaque button");
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -116,7 +115,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle(500);
         imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
 
         if (!Util.compareBufferedImages(imageInit, imageHide)) {
@@ -133,7 +132,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle(500);
         imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -144,7 +143,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle(500);
         imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -159,7 +158,7 @@
             throw new Exception("Failed to show non-opaque button");
         }
 
-        toolkit.realSync();
+        robot.waitForIdle(500);
         imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
 
         if (!Util.compareBufferedImages(imageInit, imageHide)) {
--- a/test/javax/swing/JEditorPane/6917744/bug6917744.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JEditorPane/6917744/bug6917744.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,8 +33,6 @@
 import java.io.IOException;
 import javax.swing.*;
 
-import sun.awt.SunToolkit;
-
 public class bug6917744 {
     private static JFrame frame;
 
@@ -45,7 +43,6 @@
     private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         robot = new Robot();
         robot.setAutoDelay(100);
@@ -70,13 +67,14 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         for (int i = 0; i < 50; i++) {
             robot.keyPress(KeyEvent.VK_PAGE_DOWN);
+            robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Check that we at the end of document
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -89,13 +87,14 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         for (int i = 0; i < 50; i++) {
             robot.keyPress(KeyEvent.VK_PAGE_UP);
+            robot.keyRelease(KeyEvent.VK_PAGE_UP);
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Check that we at the begin of document
         SwingUtilities.invokeAndWait(new Runnable() {
--- a/test/javax/swing/JFileChooser/4524490/bug4524490.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JFileChooser/4524490/bug4524490.java	Fri Nov 21 16:11:03 2014 +0300
@@ -25,24 +25,23 @@
  * @test
  * @bug 4524490
  * @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF
+ * @author Konstantin Eremin
  * @library ../../regtesthelpers
- * @build Util
- * @author Konstantin Eremin
+ * @library ../../../../lib/testlibrary
+ * @build Util jdk.testlibrary.OSInfo
  * @run main bug4524490
  */
 import java.awt.Robot;
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import javax.swing.*;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
 
 public class bug4524490 {
 
     private static JFileChooser fileChooser;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -56,7 +55,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
--- a/test/javax/swing/JFileChooser/7199708/bug7199708.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JFileChooser/7199708/bug7199708.java	Fri Nov 21 16:11:03 2014 +0300
@@ -37,7 +37,6 @@
 import javax.swing.AbstractButton;
 import javax.swing.JTable;
 import javax.swing.UIManager;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -56,7 +55,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -70,7 +68,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeLater(new Runnable() {
             public void run() {
@@ -108,14 +106,14 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         int d = 25;
         for (int i = 0; i < width / d; i++) {
             robot.mouseMove(locationX + i * d, locationY + 5);
             robot.mousePress(InputEvent.BUTTON1_MASK);
             robot.mouseRelease(InputEvent.BUTTON1_MASK);
-            toolkit.realSync();
+            robot.waitForIdle();
         }
 
         robot.keyPress(KeyEvent.VK_ESCAPE);
--- a/test/javax/swing/JFileChooser/8002077/bug8002077.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JFileChooser/8002077/bug8002077.java	Fri Nov 21 16:11:03 2014 +0300
@@ -22,13 +22,11 @@
  */
 
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import javax.swing.JFileChooser;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -56,27 +54,26 @@
     }
 
     private static void runTest() throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
         SwingUtilities.invokeLater(() ->
                 fileChooserState = new JFileChooser().showSaveDialog(null));
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_N);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_A);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_S);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (fileChooserState != JFileChooser.APPROVE_OPTION) {
             // Close the dialog
             Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
-            toolkit.realSync();
+            robot.waitForIdle();
 
             throw new RuntimeException("Save button is not pressed!");
         }
--- a/test/javax/swing/JFileChooser/8021253/bug8021253.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JFileChooser/8021253/bug8021253.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,7 +32,6 @@
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -50,7 +49,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -60,7 +58,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -68,11 +66,11 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(KeyEvent.VK_ENTER);
         robot.keyRelease(KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!defaultKeyPressed) {
             throw new RuntimeException("Default button is not pressed");
--- a/test/javax/swing/JFrame/4962534/bug4962534.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JFrame/4962534/bug4962534.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,7 +33,6 @@
 import java.awt.event.*;
 import java.util.Random;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class bug4962534 extends Applet {
 
@@ -45,7 +44,6 @@
     Component titleComponent;
     JLayeredPane lPane;
     volatile boolean titleFound = false;
-    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
     public static Object LOCK = new Object();
 
     @Override
@@ -91,13 +89,13 @@
                 robot = new Robot();
                 robot.setAutoDelay(70);
 
-                toolkit.realSync();
+                robot.waitForIdle();
 
                 robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
                         framePosition.y + titleComponent.getHeight() / 2);
                 robot.mousePress(InputEvent.BUTTON1_MASK);
 
-                toolkit.realSync();
+                robot.waitForIdle();
 
                 gcBounds =
                         GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getConfigurations()[0].getBounds();
@@ -105,7 +103,7 @@
                 robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
                         framePosition.y + titleComponent.getHeight() / 2);
 
-                toolkit.realSync();
+                robot.waitForIdle();
 
                 int multier = gcBounds.height / 2 - 10; //we will not go out the borders
                 for (int i = 0; i < 10; i++) {
@@ -113,7 +111,7 @@
                 }
                 robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-                toolkit.realSync();
+                robot.waitForIdle();
 
             } catch (AWTException e) {
                 throw new RuntimeException("Test Failed. AWTException thrown." + e.getMessage());
--- a/test/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java	Fri Nov 21 16:11:03 2014 +0300
@@ -22,21 +22,21 @@
  */
 
 import java.awt.Rectangle;
-import java.awt.Robot;
 import java.awt.Toolkit;
 import java.awt.image.BufferedImage;
 
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
-
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
 
 /**
  * @test
  * @bug 7124513
  * @summary We should support NSTexturedBackgroundWindowMask style on OSX.
  * @author Sergey Bylokhov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot jdk.testlibrary.OSInfo
+ * @run main NSTexturedJFrame
  */
 public final class NSTexturedJFrame {
 
@@ -46,12 +46,15 @@
     private static Rectangle bounds;
     private static volatile int step;
     private static JFrame frame;
+    private static ExtendedRobot robot;
 
     public static void main(final String[] args) throws Exception {
         if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
             System.out.println("This test is for OSX, considered passed.");
             return;
         }
+        robot = new ExtendedRobot();
+        robot.setAutoDelay(50);
         // Default window appearance
         showFrame();
         step++;
@@ -84,12 +87,10 @@
     }
 
     private static void showFrame() throws Exception {
-        final Robot robot = new Robot();
-        robot.setAutoDelay(50);
         createUI();
         images[step] = robot.createScreenCapture(bounds);
         SwingUtilities.invokeAndWait(frame::dispose);
-        sleep();
+        robot.waitForIdle(1000);
     }
 
     private static void createUI() throws Exception {
@@ -107,15 +108,11 @@
             }
             frame.setVisible(true);
         });
-        sleep();
+        robot.waitForIdle(1000);
         SwingUtilities.invokeAndWait(() -> {
             bounds = frame.getBounds();
         });
-        sleep();
+        robot.waitForIdle(1000);
     }
 
-    private static void sleep() throws InterruptedException {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
-        Thread.sleep(1000);
-    }
 }
--- a/test/javax/swing/JInternalFrame/5066752/bug5066752.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JInternalFrame/5066752/bug5066752.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,21 +32,19 @@
 
 import java.awt.*;
 import javax.swing.*;
-import sun.awt.*;
 
 public class bug5066752
 {
     private static JFrame frame;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
         Robot r = new Robot();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 createAndShowGUI();
             }
         });
-        tk.realSync();
+        r.waitForIdle();
 
         r.delay(600);
 
--- a/test/javax/swing/JInternalFrame/8020708/bug8020708.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JInternalFrame/8020708/bug8020708.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,7 +32,6 @@
 import javax.swing.JInternalFrame;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -79,7 +78,6 @@
     }
 
     static void testInternalFrameMnemonic() throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -103,25 +101,26 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point clickPoint = Util.getCenterPoint(internalFrame);
         robot.mouseMove(clickPoint.x, clickPoint.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_C);
-        toolkit.realSync();
+        robot.waitForIdle();
+        robot.delay(500);
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
                 if (internalFrame.isVisible()) {
-                    throw new RuntimeException("Close mnemonic does not work");
+                    throw new RuntimeException("Close mnemonic does not work in "+UIManager.getLookAndFeel());
                 }
                 frame.dispose();
             }
--- a/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java	Fri Nov 21 16:11:03 2014 +0300
@@ -27,8 +27,6 @@
     @author mcherkas
     @run main InternalFrameIsNotCollectedTest
  */
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.beans.PropertyVetoException;
@@ -41,12 +39,6 @@
     private static Robot robot;
     private static CustomInternalFrame iFrame;
 
-    public static void sync() {
-
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
-    }
-
     public static void main(String[] args) throws Exception {
         initRobot();
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -60,7 +52,7 @@
                 }
             }
         });
-        sync();
+        robot.waitForIdle();
         invokeGC();
         System.runFinalization();
         Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
@@ -134,4 +126,4 @@
             waiter.notifyAll();
         }
     }
-}
\ No newline at end of file
+}
--- a/test/javax/swing/JList/6462008/bug6462008.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JList/6462008/bug6462008.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,7 +32,6 @@
 import java.awt.event.*;
 import javax.swing.*;
 import java.util.*;
-import sun.awt.SunToolkit;
 
 public class bug6462008 {
 
@@ -41,11 +40,9 @@
     private static boolean isAquaLAF;
     private static int controlKey;
     private static JList list;
-    private static SunToolkit toolkit;
     private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(100);
 
@@ -60,15 +57,15 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         setAnchorLead(-1);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         testListSelection();
 
         setAnchorLead(100);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         testListSelection();
     }
@@ -79,10 +76,10 @@
         robot.keyPress(KeyEvent.VK_SPACE);
         robot.keyRelease(KeyEvent.VK_SPACE);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelection();
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Control + Space
         robot.keyPress(KeyEvent.VK_CONTROL);
@@ -90,10 +87,10 @@
         robot.keyRelease(KeyEvent.VK_SPACE);
         robot.keyRelease(KeyEvent.VK_CONTROL);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelection();
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Shift + Space
         robot.keyPress(KeyEvent.VK_SHIFT);
@@ -101,10 +98,10 @@
         robot.keyRelease(KeyEvent.VK_SPACE);
         robot.keyRelease(KeyEvent.VK_SHIFT);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelection();
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Control + Shift + Space
         robot.keyPress(KeyEvent.VK_CONTROL);
@@ -114,10 +111,10 @@
         robot.keyRelease(KeyEvent.VK_SHIFT);
         robot.keyRelease(KeyEvent.VK_CONTROL);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelection();
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         // Control + A  Multiple Selection
@@ -127,11 +124,11 @@
         robot.keyRelease(KeyEvent.VK_A);
         robot.keyRelease(controlKey);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
         resetList();
         setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Control + A Single Selection
         robot.keyPress(controlKey);
@@ -139,12 +136,12 @@
         robot.keyRelease(KeyEvent.VK_A);
         robot.keyRelease(controlKey);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(0, 0, 0);
         resetList();
         setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
         setSelectionInterval(5, 5);
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         // Control + A Selection interval (5, 5)
@@ -153,10 +150,10 @@
         robot.keyRelease(KeyEvent.VK_A);
         robot.keyRelease(controlKey);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelection(5);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Page Down
         // Not applicable for the Aqua L&F
@@ -164,10 +161,10 @@
             robot.keyPress(KeyEvent.VK_PAGE_DOWN);
             robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
 
-            toolkit.realSync();
+            robot.waitForIdle();
             checkSelection(9, 9, 9);
             resetList();
-            toolkit.realSync();
+            robot.waitForIdle();
         }
 
         // Shift + Page Down
@@ -184,28 +181,28 @@
 
         scrollDownExtendSelection();
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelection(0, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Down
         robot.keyPress(KeyEvent.VK_DOWN);
         robot.keyRelease(KeyEvent.VK_DOWN);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(0, 0, 0);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // L
         robot.keyPress(KeyEvent.VK_L);
         robot.keyRelease(KeyEvent.VK_L);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(0, 0, 0);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Click item 4
         Point p = clickItem4();
@@ -214,10 +211,10 @@
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(4, 4, 4);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         // Control + Click item 4
@@ -229,10 +226,10 @@
         robot.keyRelease(controlKey);
 
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(4, 4, 4);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Shift + Click item 4
         robot.keyPress(KeyEvent.VK_SHIFT);
@@ -243,10 +240,10 @@
         robot.keyRelease(KeyEvent.VK_SHIFT);
 
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(0, 4, 0, 1, 2, 3, 4);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         // Control + Shift + Click item 4
@@ -259,10 +256,10 @@
         robot.keyRelease(KeyEvent.VK_SHIFT);
         robot.keyRelease(controlKey);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectionAL(0, 4);
         resetList();
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 
     private static DefaultListModel getModel() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JList/6510999/bug6510999.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ *
+ * 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 6510999
+   @summary Selection in a JList with both scrollbars visible jumps on arrowkey-down
+   @author Alexander Potochkin
+   @run main bug6510999
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug6510999 {
+    private static JScrollPane s;
+
+    private static void createGui() {
+        final JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        DefaultListModel dlm = new DefaultListModel();
+        for (int i = 0; i < 100; i++)
+          dlm
+            .addElement(i + " listItemlistItemlistItemlistItemItem");
+        JList l = new JList();
+        l.setModel(dlm);
+        s = new JScrollPane(l);
+        l.setSelectedIndex(50);
+        l.ensureIndexIsVisible(50);
+
+        frame.add(s);
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+        Robot robot = new Robot();
+        robot.setAutoDelay(10);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                bug6510999.createGui();
+            }
+        });
+        robot.waitForIdle();
+        Point viewPosition = s.getViewport().getViewPosition();
+        robot.keyPress(KeyEvent.VK_DOWN);
+        robot.keyRelease(KeyEvent.VK_DOWN);
+        robot.waitForIdle();
+        if (!s.getViewport().getViewPosition().equals(viewPosition)) {
+            throw new RuntimeException("JScrollPane was unexpectedly scrolled");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenu/4417601/bug4417601.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ *
+ * 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 4417601
+   @summary JMenus with no items paint a tiny menu.
+   @author Alexander Potochkin
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @run main bug4417601
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug4417601 {
+    static JMenu menu;
+    static volatile boolean flag;
+
+    public static void main(String[] args) throws Exception {
+
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(10);
+
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                JFrame frame = new JFrame();
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                menu = new JMenu("Menu");
+                JMenuBar bar = new JMenuBar();
+                bar.add(menu);
+                frame.setJMenuBar(bar);
+
+                frame.getLayeredPane().addContainerListener(new ContainerAdapter() {
+                    public void componentAdded(ContainerEvent e) {
+                        flag = true;
+                    }
+                });
+
+                frame.pack();
+                frame.setSize(200, 200);
+                frame.setLocationRelativeTo(null);
+                frame.setVisible(true);
+            }
+        });
+        robot.waitForIdle();
+        Point p = menu.getLocationOnScreen();
+        Dimension size = menu.getSize();
+        p.x += size.width / 2;
+        p.y += size.height / 2;
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+        if (flag) {
+            throw new RuntimeException("Empty popup was shown");
+        }
+    }
+}
--- a/test/javax/swing/JMenu/4515762/bug4515762.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenu/4515762/bug4515762.java	Fri Nov 21 16:11:03 2014 +0300
@@ -24,7 +24,6 @@
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -107,7 +106,6 @@
     }
 
     public static void main(String[] args) throws Throwable {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(250);
 
@@ -123,17 +121,17 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_D);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Press the S key many times (should not cause an action peformed)
         int TIMES = 5;
         for (int i = 0; i < TIMES; i++) {
             Util.hitKeys(robot, KeyEvent.VK_S);
         }
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Unique menu items.
         actionExpected = true;
@@ -141,31 +139,31 @@
 
         robot.keyPress(KeyEvent.VK_S);
         robot.keyRelease(KeyEvent.VK_S);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
 
         Util.hitMnemonics(robot, KeyEvent.VK_U);
         robot.keyPress(KeyEvent.VK_M);
         robot.keyRelease(KeyEvent.VK_M);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
 
         Util.hitMnemonics(robot, KeyEvent.VK_U);
         Util.hitKeys(robot, KeyEvent.VK_T);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
         Util.hitMnemonics(robot, KeyEvent.VK_U);
         Util.hitKeys(robot, KeyEvent.VK_W);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
 
         Util.hitMnemonics(robot, KeyEvent.VK_U);
         Util.hitKeys(robot, KeyEvent.VK_U);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
     }
--- a/test/javax/swing/JMenu/4692443/bug4692443.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenu/4692443/bug4692443.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,7 +35,6 @@
 import javax.swing.event.*;
 import java.awt.event.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 
 public class bug4692443 {
 
@@ -56,29 +55,23 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        robo.waitForIdle();
 
-        try {
-                robo = new Robot();
-            } catch (AWTException e) {
-                throw new RuntimeException("Robot could not be created");
-            }
-            int altKey = java.awt.event.KeyEvent.VK_ALT;
-            robo.setAutoDelay(100);
-            Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu
-            robo.keyPress(KeyEvent.VK_S);  // Enter submenu
-            robo.keyRelease(KeyEvent.VK_S);
-            robo.keyPress(KeyEvent.VK_O); // Launch "One" action
-            robo.keyRelease(KeyEvent.VK_O);
-            robo.keyPress(KeyEvent.VK_M); // Launch "One" action
-            robo.keyRelease(KeyEvent.VK_M);
+        int altKey = java.awt.event.KeyEvent.VK_ALT;
+        robo.setAutoDelay(100);
+        Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu
+        robo.keyPress(KeyEvent.VK_S);  // Enter submenu
+        robo.keyRelease(KeyEvent.VK_S);
+        robo.keyPress(KeyEvent.VK_O); // Launch "One" action
+        robo.keyRelease(KeyEvent.VK_O);
+        robo.keyPress(KeyEvent.VK_M); // Launch "One" action
+        robo.keyRelease(KeyEvent.VK_M);
 
-            toolkit.realSync();
+        robo.waitForIdle();
 
-            if (!passed) {
-                throw new RuntimeException("Test failed.");
-            }
+        if (!passed) {
+            throw new RuntimeException("Test failed.");
+        }
 
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenu/6359669/bug6359669.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ *
+ * 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 6359669
+   @summary REGRESSION: Submenu does not work if populated in PopupMenuListener.popupMenuWillBecomeVisible
+   @author Alexander Potochkin
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @run main bug6359669
+*/
+
+import javax.swing.*;
+import javax.swing.event.PopupMenuListener;
+import javax.swing.event.PopupMenuEvent;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6359669 {
+    static JMenu menu;
+
+    public static void main(String[] args) throws Exception {
+
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(10);
+
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                JFrame f = new JFrame();
+                JMenuBar menuBar = new JMenuBar();
+                menu = new JMenu("Test");
+                menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {
+                    public void popupMenuCanceled(PopupMenuEvent e) {
+                    }
+
+                    public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+                    }
+
+                    public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+                        menu.add(new JMenuItem("An item"));
+                    }
+                });
+
+                menuBar.add(menu);
+                f.setJMenuBar(menuBar);
+
+                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                f.setSize(200, 200);
+                f.setVisible(true);
+            }
+        });
+        robot.waitForIdle();
+        Point p = menu.getLocationOnScreen();
+        Dimension size = menu.getSize();
+        p.x += size.width / 2;
+        p.y += size.height / 2;
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+        if (menu.getPopupMenu().getComponentCount() == 0) {
+            throw new RuntimeException("Where is a menuItem ?");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenu/6470128/bug6470128.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ *
+ * 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 6470128
+   @summary Escape Key causes JMenu Selection to Disappear
+   @author Alexander Potochkin
+   @library ../../../../lib/testlibrary
+   @build jdk.testlibrary.OSInfo
+   @run main bug6470128
+*/
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import jdk.testlibrary.OSInfo;
+
+public class bug6470128 {
+    static JFrame frame;
+    static JMenu subMenu;
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame = new JFrame();
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+                JMenuBar bar = new JMenuBar();
+                JMenu menu = new JMenu("Menu");
+                menu.setMnemonic('m');
+                subMenu = new JMenu("SubMenu");
+                JMenuItem item = new JMenuItem("Item");
+
+                frame.setJMenuBar(bar);
+                bar.add(menu);
+                menu.add(subMenu);
+                subMenu.add(item);
+
+                frame.setSize(200, 200);
+                frame.setLocationRelativeTo(null);
+                frame.setVisible(true);
+            }
+        });
+        Robot robot = new Robot();
+        robot.setAutoDelay(10);
+        robot.waitForIdle();
+        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+            robot.keyPress(KeyEvent.VK_CONTROL);
+        }
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_M);
+        robot.keyRelease(KeyEvent.VK_M);
+        robot.keyRelease(KeyEvent.VK_ALT);
+        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+            robot.keyRelease(KeyEvent.VK_CONTROL);
+        }
+        robot.keyPress(KeyEvent.VK_ENTER);
+        robot.keyRelease(KeyEvent.VK_ENTER);
+        robot.keyPress(KeyEvent.VK_ESCAPE);
+        robot.keyRelease(KeyEvent.VK_ESCAPE);
+        robot.waitForIdle();
+        if (!subMenu.isSelected()) {
+            throw new RuntimeException("Submenu is unexpectedly unselected");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenu/6538132/bug6538132.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ *
+ * 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 6538132
+   @summary Regression: Pressing Escape key don't close the menu items from jdk7.0 b07 onwards
+   @author Alexander Potochkin
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @run main bug6538132
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6538132 {
+    private static JMenu menu1;
+    private static JMenu menu2;
+    private static volatile boolean isWinLaf;
+
+    private static void createGui() {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+            isWinLaf = true;
+        } catch (Exception e) {
+            // If we can't set WinLaf it means we are not under Windows
+            // make the test pass
+            isWinLaf = false;
+            return;
+        }
+        JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JMenuBar menuBar = new JMenuBar();
+        menu1 = createMenu();
+        menuBar.add(menu1);
+        menu2 = createMenu();
+        menuBar.add(menu2);
+        frame.setJMenuBar(menuBar);
+
+        frame.setSize(200, 200);
+        frame.setVisible(true);
+    }
+
+    static JMenu createMenu() {
+        JMenu menu = new JMenu("Menu");
+        menu.add(new JMenuItem("MenuItem"));
+        menu.add(new JMenuItem("MenuItem"));
+        menu.add(new JMenuItem("MenuItem"));
+        return menu;
+    }
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                bug6538132.createGui();
+            }
+        });
+        if(isWinLaf) {
+            ExtendedRobot robot = new ExtendedRobot();
+            robot.setAutoDelay(10);
+            robot.waitForIdle();
+            Point p1 = menu1.getLocationOnScreen();
+            final int x1 = p1.x + menu1.getWidth() / 2;
+            final int y1 = p1.y + menu1.getHeight() / 2;
+            robot.glide(0, 0, x1, y1);
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+            assertPopupOpen();
+            Point p2 = menu2.getLocationOnScreen();
+            final int x2 = p2.x + menu2.getWidth() / 2;
+            final int y2 = p2.y + menu2.getHeight() / 2;
+            robot.glide(x1, y1, x2, y2);
+            assertPopupOpen();
+            robot.keyPress(KeyEvent.VK_ESCAPE);
+            robot.keyRelease(KeyEvent.VK_ESCAPE);
+            assertPopupNotOpen();
+            robot.glide(x2, y2, x1, y1);
+            assertPopupNotOpen();
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+            assertPopupOpen();
+        }
+    }
+
+    static void assertPopupOpen() {
+        if (getLastPopup() == null) {
+            throw new RuntimeException("PopupMenu is not open");
+        }
+    }
+
+    static void assertPopupNotOpen() {
+        if (getLastPopup() != null) {
+            throw new RuntimeException("PopupMenu is unexpectedly open");
+        }
+    }
+
+    // copied from BasicPopupMenuUI
+    static JPopupMenu getLastPopup() {
+        MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+        MenuElement[] p = msm.getSelectedPath();
+        JPopupMenu popup = null;
+
+        for (int i = p.length - 1; popup == null && i >= 0; i--) {
+            if (p[i] instanceof JPopupMenu)
+                popup = (JPopupMenu) p[i];
+        }
+        return popup;
+    }
+}
--- a/test/javax/swing/JMenuBar/4750590/bug4750590.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenuBar/4750590/bug4750590.java	Fri Nov 21 16:11:03 2014 +0300
@@ -48,16 +48,15 @@
             }
         });
 
-        sun.awt.SunToolkit toolkit = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
-
         Robot robo = new Robot();
         robo.setAutoDelay(500);
+        robo.waitForIdle();
+
         Util.hitMnemonics(robo, KeyEvent.VK_F);
         robo.keyPress(KeyEvent.VK_M);
         robo.keyRelease(KeyEvent.VK_M);
 
-        toolkit.realSync();
+        robo.waitForIdle();
 
         if (passed) {
             System.out.println("Test passed!");
--- a/test/javax/swing/JMenuItem/4171437/bug4171437.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenuItem/4171437/bug4171437.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,7 +32,6 @@
 import java.util.ArrayList;
 import javax.swing.*;
 import javax.swing.event.*;
-import sun.awt.SunToolkit;
 
 public class bug4171437 {
     static volatile boolean closeActivated = false;
@@ -45,16 +44,14 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
-
         Robot robot = new Robot();
         robot.setAutoDelay(50);
+        robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_F);
         Util.hitKeys(robot, KeyEvent.VK_C);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         if (!closeActivated || customActivated) {
--- a/test/javax/swing/JMenuItem/4654927/bug4654927.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenuItem/4654927/bug4654927.java	Fri Nov 21 16:11:03 2014 +0300
@@ -36,7 +36,6 @@
 import java.awt.*;
 import java.awt.event.InputEvent;
 import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
 
 public class bug4654927 {
 
@@ -51,7 +50,6 @@
         }
 
         UIManager.setLookAndFeel(systemLAF);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(10);
 
@@ -61,20 +59,20 @@
                 createAndShowUI();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // test mouse press
         Point point = Util.getCenterPoint(menu);
         robot.mouseMove(point.x, point.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         point = Util.getCenterPoint(menuItem);
         robot.mouseMove(point.x, point.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!isMenuItemShowing()) {
             throw new RuntimeException("Popup is unexpectedly closed");
@@ -107,12 +105,12 @@
         // close menu
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.mousePress(InputEvent.BUTTON1_MASK);
         Util.glide(robot, x0, y0, x1, y1);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!isMenuItemShowing()) {
             throw new RuntimeException("Popup is unexpectedly closed");
--- a/test/javax/swing/JMenuItem/6209975/bug6209975.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenuItem/6209975/bug6209975.java	Fri Nov 21 16:11:03 2014 +0300
@@ -25,15 +25,12 @@
  * @test
  * @bug 6209975
  * @summary regression: JMenuItem icons overimposed on JMenuItem labels under Metal LAF
- * @library ../../regtesthelpers
- * @build Util
  * @author Alexander Zuev
  * @run main bug6209975
  */
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.InputEvent;
-import sun.awt.SunToolkit;
 
 public class bug6209975 {
 
@@ -45,7 +42,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(500);
 
@@ -58,19 +54,19 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point clickPoint = getButtonClickPoint();
         robot.mouseMove(clickPoint.x, clickPoint.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickPoint = getMenuClickPoint();
         robot.mouseMove(clickPoint.x, clickPoint.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (RO1.itsValue <= RO2.itsValue) {
             throw new RuntimeException("Offset if the second icon is invalid.");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenuItem/6249972/bug6249972.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ *
+ * 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 6249972
+   @summary Tests that JMenuItem(String,int) handles lower-case mnemonics properly.
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @author Mikhail Lapshin
+   @run main bug6249972
+ */
+
+import javax.swing.*;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6249972 implements ActionListener {
+
+
+    private JFrame frame;
+    private JMenu menu;
+    private volatile boolean testPassed = false;
+
+    public static void main(String[] args) throws Exception {
+        bug6249972 bugTest = new bug6249972();
+        bugTest.test();
+    }
+
+    public bug6249972() throws Exception {
+        SwingUtilities.invokeAndWait(
+                new Runnable() {
+                    public void run() {
+                        frame = new JFrame("bug6249972");
+                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+                        JMenuBar bar = new JMenuBar();
+                        frame.setJMenuBar(bar);
+
+                        menu = new JMenu("Problem");
+                        bar.add(menu);
+
+                        JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z');
+                        item.addActionListener(bug6249972.this);
+                        menu.add(item);
+
+                        frame.setLocationRelativeTo(null);
+                        frame.pack();
+                        frame.setVisible(true);
+                    }
+                }
+        );
+    }
+
+
+    private void test() throws Exception {
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.waitForIdle();
+        java.awt.Point p = menu.getLocationOnScreen();
+        java.awt.Dimension size = menu.getSize();
+        p.x += size.width / 2;
+        p.y += size.height / 2;
+        robot.mouseMove(p.x, p.y);
+        robot.click();
+        robot.delay(100);
+
+        robot.waitForIdle();
+        robot.type(KeyEvent.VK_Z);
+
+        robot.waitForIdle();
+        frame.dispose(); // Try to stop the event dispatch thread
+
+        if (!testPassed) {
+            throw new RuntimeException("JMenuItem(String,int) does not handle " +
+                    "lower-case mnemonics properly.");
+        }
+
+        System.out.println("Test passed");
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        // We are in the actionPerformed() method -
+        // JMenuItem(String,int) handles lower-case mnemonics properly
+        testPassed = true;
+    }
+}
--- a/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Fri Nov 21 16:11:03 2014 +0300
@@ -26,10 +26,12 @@
  * @bug 7160951
  * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  * @author vera.akulova@oracle.com
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
  * @run main ActionListenerCalledTwiceTest
  */
 
-import sun.awt.*;
+import jdk.testlibrary.OSInfo;
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
@@ -47,7 +49,7 @@
 
     static volatile int listenerCallCounter = 0;
     public static void main(String[] args) throws Exception {
-        if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
             return;
         }
@@ -59,7 +61,6 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(100);
 
@@ -78,7 +79,7 @@
                 robot.keyRelease(modKeyCode);
             }
 
-            toolkit.realSync();
+            robot.waitForIdle();
 
             if (listenerCallCounter != 1) {
                 throw new Exception("Test failed: ActionListener for " + menuItems[i] +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JOptionPane/6428694/bug6428694.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ *
+ * 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 6428694
+@summary Checks that double click closes JOptionPane's input dialog.
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@author Mikhail Lapshin
+@run main bug6428694
+*/
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.JOptionPane;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6428694 {
+    private static JFrame frame;
+    private static boolean mainIsWaitingForDialogClosing;
+    private static ExtendedRobot robot;
+    private static volatile boolean testPassed;
+
+    public static void main(String[] args) throws Exception {
+        robot = new ExtendedRobot();
+        try {
+            SwingUtilities.invokeLater(new Runnable() {
+                public void run() {
+                    bug6428694.setupUI();
+                }
+            });
+            robot.waitForIdle();
+            test();
+        } finally {
+            stopEDT();
+        }
+
+        if (testPassed) {
+            System.out.println("Test passed");
+        } else {
+            throw new RuntimeException("JOptionPane doesn't close input dialog " +
+                    "by double click!");
+        }
+    }
+
+    private static void setupUI() {
+        frame = new JFrame("bug6428694 test");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setVisible(true);
+
+        Object[] selectedItems = new Object[40];
+        for (int i = 0; i < 39; i++) {
+            selectedItems[i] = ("item: " + i);
+        }
+        JOptionPane.showInputDialog(frame,
+                "Double click on selected item then click cancel",
+                "Test Option Dialog", JOptionPane.WARNING_MESSAGE, null,
+                selectedItems, selectedItems[0]);
+
+        // We are here if double click has closed the dialog
+        // or when the EDT is stopping
+        testPassed = mainIsWaitingForDialogClosing;
+    }
+
+    private static void test() {
+
+        mainIsWaitingForDialogClosing = true;
+
+        // Perform double click on an item
+        int frameLeftX = frame.getLocationOnScreen().x;
+        int frameUpperY = frame.getLocationOnScreen().y;
+        robot.mouseMove(frameLeftX + 150, frameUpperY + 120);
+        robot.waitForIdle();
+        robot.delay(100);
+        robot.setAutoDelay(50);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        // Wait for the input dialog closing
+        robot.waitForIdle();
+        robot.delay(2000);
+
+        mainIsWaitingForDialogClosing = false;
+    }
+
+    private static void stopEDT() {
+        if (frame != null) {
+            frame.dispose();
+        }
+    }
+}
--- a/test/javax/swing/JOptionPane/7138665/bug7138665.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JOptionPane/7138665/bug7138665.java	Fri Nov 21 16:11:03 2014 +0300
@@ -27,8 +27,6 @@
    @author Pavel Porvatov
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.KeyEvent;
@@ -55,16 +53,14 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
 
-        toolkit.realSync();
-
-        Robot robot = new Robot();
+        robot.waitForIdle();
 
         robot.setAutoDelay(100);
         robot.keyPress(KeyEvent.VK_ENTER);
         robot.keyRelease(KeyEvent.VK_ENTER);
 
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 }
--- a/test/javax/swing/JPopupMenu/4458079/bug4458079.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JPopupMenu/4458079/bug4458079.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,7 +35,6 @@
 import javax.swing.event.*;
 import java.awt.event.KeyEvent;
 import java.util.ArrayList;
-import sun.awt.SunToolkit;
 
 public class bug4458079 extends JFrame implements PopupMenuListener {
     public JMenu menu;
@@ -47,21 +46,20 @@
                 new bug4458079().createAndShowGUI();
             }
         });
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
 
-        Robot robot = new Robot();
         robot.setAutoDelay(50);
 
         Util.hitMnemonics(robot, KeyEvent.VK_M);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         Util.hitKeys(robot, KeyEvent.VK_DOWN);
         Util.hitKeys(robot, KeyEvent.VK_ENTER);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         if (!itemASelected) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/4634626/bug4634626.html	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,8 @@
+<Html>
+<Body>
+<APPLET  code="bug4634626.class" WIDTH = 50 HEIGHT = 50>
+</APPLET>
+
+</Body>
+</Html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/4634626/bug4634626.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2003, 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.
+ *
+ * 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 4634626
+   @summary Implement context popup menus for components
+   @author Alexander Zuev
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @run applet bug4634626.html
+*/
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug4634626 extends JApplet {
+
+    public boolean passed = true;
+    public boolean done = false;
+
+    public JFrame mainFrame = new JFrame("Bug4634626");
+    public JRootPane rootPane = mainFrame.getRootPane();
+    public JPanel contentPane = new JPanel();
+    public JButton nopButton = new JButton("No popup button");
+    public JTextArea someText = new JTextArea("Some text here", 20, 10);
+    public JButton popButton = new JButton("Button with the popup");
+
+    public JPopupMenu btnPopup = new JPopupMenu();
+    public JPopupMenu commonPopup = new JPopupMenu();
+    static public Error toBeThrown = null;
+    static int popTrig = MouseEvent.BUTTON3_MASK;
+    static boolean popt = false;
+
+    public static class MouseWatcher extends MouseAdapter {
+        public void mousePressed(MouseEvent e) {
+            if(e.isPopupTrigger()) popt = true;
+            if(e.getComponent() != null &&
+               e.getComponent() instanceof JComponent &&
+               e.isPopupTrigger() &&
+               ((JComponent)e.getComponent()).getComponentPopupMenu() != null) {
+                toBeThrown =
+                  new Error("The event got thru the component with popup: "
+                  + e);
+            }
+        }
+        public void mouseReleased(MouseEvent e) {
+            if(e.isPopupTrigger()) popt = true;
+            if(e.getComponent() != null &&
+               e.getComponent() instanceof JComponent &&
+               e.isPopupTrigger() &&
+               ((JComponent)e.getComponent()).getComponentPopupMenu() != null) {
+                toBeThrown =
+                  new Error("The event got thru the component with popup: "
+                  + e);
+            }
+            if(toBeThrown != null) {
+                throw(toBeThrown);
+            }
+        }
+    }
+
+    public static MouseWatcher mouser = new MouseWatcher();
+
+    public void init() {
+
+        try {
+            popButton.setComponentPopupMenu(null);
+            popButton.setComponentPopupMenu(null);
+            popButton.setComponentPopupMenu(btnPopup);
+            popButton.setComponentPopupMenu(null);
+        } catch(Exception ex) {
+            System.err.println("Unexpected exception was thrown by " +
+                               "setComponentPopupMenu() method: " + ex);
+        }
+        btnPopup.add("Button 1");
+        btnPopup.add("Button 2");
+        btnPopup.add("Button 3");
+        popButton.setComponentPopupMenu(btnPopup);
+        popButton.addMouseListener(mouser);
+        commonPopup.add("One");
+        commonPopup.add("Two");
+        commonPopup.add("Three");
+
+        contentPane.setLayout(new BorderLayout());
+        contentPane.setComponentPopupMenu(commonPopup);
+        contentPane.addMouseListener(mouser);
+        contentPane.add(nopButton, BorderLayout.NORTH);
+        nopButton.addMouseListener(mouser);
+        contentPane.add(popButton, BorderLayout.SOUTH);
+        someText.addMouseListener(mouser);
+        contentPane.add(someText, BorderLayout.CENTER);
+        mainFrame.setContentPane(contentPane);
+
+        mainFrame.pack();
+        mainFrame.setLocation(50, 50);
+
+        mainFrame.addWindowListener(new TestStateListener());
+        mainFrame.setVisible(true);
+
+        while(!done) Thread.yield();
+
+        if(!passed) {
+            throw new RuntimeException("Test failed");
+        }
+
+    }
+
+    public class TestStateListener extends WindowAdapter {
+        public void windowOpened(WindowEvent ev) {
+            try {
+                ev.getWindow().toFront();
+                ev.getWindow().requestFocus();
+                new Thread(new RobotThread()).start();
+            } catch (Exception ex) {
+                throw new RuntimeException("Thread Exception");
+            }
+        }
+    }
+
+    class RobotThread implements Runnable {
+        public void run() {
+            ExtendedRobot robo;
+            try {
+                robo = new ExtendedRobot();
+            }catch(Exception ex) {
+                ex.printStackTrace();
+                throw new RuntimeException("Cannot create Robot");
+            }
+            robo.setAutoDelay(100);
+            robo.waitForIdle();
+
+            // Determine working popup trigger event
+            clickMouseOn(robo, nopButton, popTrig);
+            robo.waitForIdle();
+            robo.delay(500);
+            if(!popt) popTrig = MouseEvent.BUTTON2_MASK;
+
+            // Inheritance is OFF by default. Popup should not appear.
+            clickMouseOn(robo, someText, popTrig);
+
+            // Set inheritance ON watch for popup.
+            someText.setInheritsPopupMenu(true);
+            clickMouseOn(robo, someText, popTrig);
+            robo.waitForIdle();
+            robo.delay(500);
+            if(!commonPopup.isVisible()) {
+                toBeThrown = new Error("Popup should be visible");
+                passed = false;
+            }
+            // Dispose popup.
+            robo.type(KeyEvent.VK_ESCAPE);
+            robo.waitForIdle();
+            someText.setInheritsPopupMenu(false);
+
+            // Button with popup assigned. Wathch for popup.
+            clickMouseOn(robo, popButton, popTrig);
+            robo.waitForIdle();
+            robo.delay(500);
+            if(!btnPopup.isVisible()) {
+                toBeThrown = new Error("Popup should be visible");
+                passed = false;
+            }
+            // Dispose popup.
+            robo.type(KeyEvent.VK_ESCAPE);
+            // Test finished.
+            done = true;
+        }
+    }
+
+
+
+    public void destroy() {
+        if(!passed) {
+            throw(toBeThrown);
+        }
+    }
+    private void clickMouseOn(ExtendedRobot robot, Component c, int button) {
+        java.awt.Point p = c.getLocationOnScreen();
+        java.awt.Dimension size = c.getSize();
+        p.x += size.width / 2;
+        p.y += size.height / 2;
+        robot.mouseMove(p.x, p.y);
+        robot.delay(100);
+        robot.click(button);
+    }
+}
--- a/test/javax/swing/JPopupMenu/4966112/bug4966112.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JPopupMenu/4966112/bug4966112.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,7 +35,6 @@
 import javax.swing.event.PopupMenuEvent;
 import java.awt.*;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
 
 public class bug4966112 {
 
@@ -50,19 +49,18 @@
     private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(100);
 
         createAndShowButton();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         setClickPoint(testButton);
         clickMouse(InputEvent.BUTTON1_MASK);
         clickMouse(InputEvent.BUTTON2_MASK);
         clickMouse(InputEvent.BUTTON3_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         closeFrame();
 
         if (popupButton == NO_MOUSE_BUTTON) {
@@ -74,10 +72,10 @@
 
         // Test Split Pane
         createAndShowSplitPane();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickMouse(jsp);
-        toolkit.realSync();
+        robot.waitForIdle();
         closeFrame();
 
         if (!shown) {
@@ -86,10 +84,10 @@
 
         // Test Spinner
         createAndShowSpinner();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickMouse(spin);
-        toolkit.realSync();
+        robot.waitForIdle();
         closeFrame();
 
         if (!shown) {
@@ -98,16 +96,16 @@
 
         // Test File Chooser
         createAndShowFileChooser();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickMouse(filec);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
-        toolkit.realSync();
+        robot.waitForIdle();
         closeFrame();
 
         if (!shown) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6217905/bug6217905.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ *
+ * 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 6217905
+@summary JPopupMenu keyboard navigation stops working
+@author Alexander Potochkin
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@run main bug6217905
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6217905 {
+    private static JPanel popupPanel;
+    private static JMenuItem firstItem;
+    private static JMenuItem lastItem;
+
+    private static void createGui() {
+        final JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JPopupMenu popup = new JPopupMenu("Menu");
+        firstItem = new JMenuItem("MenuItem");
+        popup.add(firstItem);
+        popup.add(new JMenuItem("MenuItem"));
+        lastItem = new JMenuItem("MenuItem");
+        popup.add(lastItem);
+
+        popupPanel = new JPanel();
+        popupPanel.setComponentPopupMenu(popup);
+        frame.add(popupPanel);
+        frame.setSize(100, 100);
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+        } catch (Exception e) {
+            // This test is for WinLaf only
+            System.out.println("This test is for Windows LaF only.");
+            return;
+        }
+
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(10);
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                bug6217905.createGui();
+            }
+        });
+        robot.waitForIdle();
+        Point loc = popupPanel.getLocationOnScreen();
+        int x = loc.x + popupPanel.getWidth()/2;
+        int y = loc.y + popupPanel.getHeight()/2;
+        robot.glide(0, 0, x, y);
+        robot.mousePress(InputEvent.BUTTON3_MASK);
+        robot.mouseRelease(InputEvent.BUTTON3_MASK);
+        robot.waitForIdle();
+        if (getSelectedPathLength() != 1) {
+            throw new RuntimeException("Only popup must be selected");
+        }
+        robot.glide(x, y, 0, 0);
+        robot.type(KeyEvent.VK_DOWN);
+        robot.waitForIdle();
+        if (getSelectedPathLength() != 2 || !firstItem.isArmed()) {
+            throw new RuntimeException("First item must be selected");
+        }
+        robot.type(KeyEvent.VK_ESCAPE);
+        robot.waitForIdle();
+        if (getSelectedPathLength() != 0) {
+            throw new RuntimeException("There must be no selected items");
+        }
+        robot.glide(0, 0, x, y);
+        robot.mousePress(InputEvent.BUTTON3_MASK);
+        robot.mouseRelease(InputEvent.BUTTON3_MASK);
+        robot.waitForIdle();
+        robot.glide(x, y, 0, 0);
+        robot.type(KeyEvent.VK_UP);
+        robot.waitForIdle();
+        if (getSelectedPathLength() != 2 || !lastItem.isArmed()) {
+            throw new RuntimeException("Last item must be selected");
+        }
+    }
+
+    private static int getSelectedPathLength() {
+        return MenuSelectionManager.defaultManager().getSelectedPath().length;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6415145/bug6415145.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ *
+ * 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 6415145
+@summary REGRESSION: Selected item is not being updated while dragging above popup menu
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@author Mikhail Lapshin
+@run main bug6415145
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.AWTException;
+import java.awt.Component;
+
+public class bug6415145 {
+    private JFrame frame;
+    private JButton button;
+    private JPopupMenu popupMenu;
+    private JMenuItem item1;
+    private JMenuItem item2;
+    private static ExtendedRobot robot;
+
+    public static void main(String[] args) throws Exception {
+        robot = new ExtendedRobot();
+        final bug6415145 bugTest = new bug6415145();
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    bugTest.init();
+                }
+            });
+
+            robot.waitForIdle();
+            bugTest.test();
+        } finally {
+            bugTest.stopEDT();
+        }
+    }
+
+    private void stopEDT() {
+        if (frame != null) {
+            frame.dispose();
+        }
+    }
+
+    private void init() {
+        popupMenu = new JPopupMenu("test menu");
+        item1 = new JMenuItem("item 1");
+        item2 = new JMenuItem("item 2");
+        popupMenu.add(item1);
+        popupMenu.add(item2);
+
+        button = new JButton("test button");
+        button.addMouseListener(new MouseListener());
+
+        frame = new JFrame("test frame");
+        frame.add(popupMenu);
+        frame.add(button);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    private class MouseListener extends MouseAdapter {
+        public void mousePressed(MouseEvent e) {
+            popupMenu.show(button, e.getX(), e.getY());
+        }
+    }
+
+    private void test() throws AWTException {
+        try {
+            moveMouseTo(robot, button);
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.waitForIdle();
+
+            moveMouseTo(robot, item1);
+            robot.waitForIdle();
+
+            moveMouseTo(robot, item2);
+            robot.waitForIdle();
+            if ( (item1.isArmed()) || (!item2.isArmed()) ) {
+                throw new RuntimeException("Selected item is not being updated" +
+                        " while dragging above popup menu.");
+            }
+        } finally {
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        }
+    }
+    private void moveMouseTo(ExtendedRobot robot, Component c) {
+        java.awt.Point p = c.getLocationOnScreen();
+        java.awt.Dimension size = c.getSize();
+        p.x += size.width / 2;
+        p.y += size.height / 2;
+        robot.mouseMove(p.x, p.y);
+        robot.delay(100);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6515446/bug6515446.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2007, 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.
+ *
+ * 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 6515446
+@summary JMenuItems in JPopupMenus not receiving ActionEvents - incompat with 1.5
+@author Alexander Potochkin
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@run main bug6515446
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug6515446 {
+    private static JPanel panel;
+    private static volatile boolean flag;
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                final JFrame frame = new JFrame();
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+                final JPopupMenu popup = new JPopupMenu("Menu");
+                JMenuItem item = new JMenuItem("MenuItem");
+                item.addActionListener(new ActionListener() {
+                    public void actionPerformed(ActionEvent e) {
+                        flag = true;
+                    }
+                });
+                popup.add(item);
+
+                panel = new JPanel();
+                panel.addMouseListener(new MouseAdapter() {
+                    public void mousePressed(MouseEvent e) {
+                        popup.show(panel, e.getX(), e.getY());
+                    }
+
+                    public void mouseReleased(MouseEvent e) {
+                        popup.setVisible(false);
+                    }
+                });
+                frame.add(panel);
+                frame.setSize(200, 200);
+                frame.setLocationRelativeTo(null);
+                frame.setVisible(true);
+            }
+        });
+
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(10);
+        robot.waitForIdle();
+
+        Point l = panel.getLocationOnScreen();
+
+        int x = l.x + panel.getWidth() / 2;
+        int y = l.y + panel.getHeight() / 2;
+        robot.mouseMove(x, y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.glide(x, y, x + 10, y + 10);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+
+        if (!flag) {
+            throw new RuntimeException("ActionEvent wasn't fired");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6544309/bug6544309.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ *
+ * 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 6544309
+   @summary Checks that 'Select Input Method' popup menu allows to select
+            items with keyboard.
+   @author Mikhail Lapshin
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @run main bug6544309
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug6544309 {
+    private JDialog dialog;
+    private boolean passed;
+    private static ExtendedRobot robot;
+
+    public static void main(String[] args) throws Exception {
+        robot = new ExtendedRobot();
+        final bug6544309 test = new bug6544309();
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    test.setupUI();
+                }
+            });
+            test.test();
+            System.out.println("Test passed");
+        } finally {
+            if (test.dialog != null) {
+                test.dialog.dispose();
+            }
+        }
+    }
+
+    private void setupUI() {
+        dialog = new JDialog();
+        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+        dialog.setSize(200, 100);
+        dialog.setLocationRelativeTo(null);
+        dialog.setVisible(true);
+
+        JPopupMenu popup = new JPopupMenu();
+        popup.add(new JMenuItem("one"));
+        JMenuItem two = new JMenuItem("two");
+        two.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                passed = true;
+            }
+        });
+        popup.add(two);
+        popup.add(new JMenuItem("three"));
+        popup.show(dialog, 50, 50);
+    }
+
+    private void test() throws Exception {
+        testImpl();
+        checkResult();
+    }
+
+
+    private void testImpl() throws Exception {
+        robot.waitForIdle();
+        System.out.println("Pressing DOWN ARROW");
+        robot.type(KeyEvent.VK_DOWN);
+        robot.waitForIdle();
+        System.out.println("Pressing DOWN ARROW");
+        robot.type(KeyEvent.VK_DOWN);
+        robot.waitForIdle();
+        System.out.println("Pressing SPACE");
+        robot.type(KeyEvent.VK_SPACE);
+    }
+
+    private void checkResult() {
+        robot.waitForIdle();
+        if (!passed) {
+            throw new RuntimeException("If a JDialog is invoker for JPopupMenu, " +
+                    "the menu cannot be handled by keyboard.");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6580930/bug6580930.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2007, 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.
+ *
+ * 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 6580930 7184956
+@summary Swing Popups should overlap taskbar
+@author Alexander Potochkin
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@run main bug6580930
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6580930 {
+    private static ExtendedRobot robot;
+    private static JFrame frame;
+    private static JPopupMenu popup;
+    private static Toolkit toolkit;
+    private static volatile boolean skipTest = false;
+
+    private static void createGui() {
+        frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setUndecorated(true);
+
+        popup = new JPopupMenu("Menu");
+        for (int i = 0; i < 7; i++) {
+            popup.add(new JMenuItem("MenuItem"));
+        }
+        JPanel panel = new JPanel();
+        panel.setComponentPopupMenu(popup);
+        frame.add(panel);
+
+        frame.setSize(200, 200);
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JPopupMenu.setDefaultLightWeightPopupEnabled(true);
+                bug6580930.createGui();
+            }
+        });
+
+        toolkit = Toolkit.getDefaultToolkit();
+        robot = new ExtendedRobot();
+        robot.setAutoDelay(10);
+        robot.waitForIdle();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                Insets insets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
+                if (insets.bottom == 0) {
+                    System.out.println("This test is only for configurations with taskbar on the bottom");
+
+                    skipTest = true;
+                }
+
+                Dimension screenSize = toolkit.getScreenSize();
+                frame.setLocation(screenSize.width/2, screenSize.height - frame.getHeight() - insets.bottom + 10);
+                frame.setVisible(true);
+            }
+        });
+
+        robot.waitForIdle();
+
+        if(skipTest) {
+            return;
+        }
+        Point loc = frame.getLocationOnScreen();
+
+        robot.mouseMove(loc.x, loc.y);
+        showPopup();
+        robot.waitForIdle();
+        if (isHeavyWeightMenuVisible()) {
+            throw new RuntimeException("HeavyWeightPopup is unexpectedly visible");
+        }
+
+        robot.keyPress(KeyEvent.VK_ESCAPE);
+        robot.keyRelease(KeyEvent.VK_ESCAPE);
+
+        int x = loc.x;
+        int y = loc.y + (frame.getHeight() - popup.getPreferredSize().height) + 1;
+        robot.mouseMove(x, y);
+
+        showPopup();
+
+        if (!popup.getLocationOnScreen().equals(new Point(x, y))) {
+            throw new RuntimeException("Popup is unexpectedly shifted");
+        }
+
+        if (!isHeavyWeightMenuVisible()) {
+            throw new RuntimeException("HeavyWeightPopup is unexpectedly hidden");
+        }
+    }
+
+    private static void showPopup() {
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+        if (!popup.isShowing()) {
+            robot.mousePress(InputEvent.BUTTON2_MASK);
+            robot.mouseRelease(InputEvent.BUTTON2_MASK);
+            robot.waitForIdle();
+            if (!popup.isShowing()) {
+                robot.mousePress(InputEvent.BUTTON3_MASK);
+                robot.mouseRelease(InputEvent.BUTTON3_MASK);
+                robot.waitForIdle();
+            }
+        }
+    }
+
+    private static boolean isHeavyWeightMenuVisible() {
+        Window[] windows = Window.getWindows();
+        for (Window window : windows) {
+            if (window.getClass().getSimpleName().equals("HeavyWeightWindow")
+                    && window.isVisible()) {
+                    return true;
+            }
+        }
+        return false;
+    }
+}
--- a/test/javax/swing/JPopupMenu/6800513/bug6800513.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JPopupMenu/6800513/bug6800513.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,8 +32,6 @@
  * @run main bug6800513
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.InputEvent;
@@ -47,10 +45,10 @@
     private static JPopupMenu popupMenu;
     private static JMenu menu;
     private static JFrame frame;
+    private static Robot robot;
 
     public static void testFrame(final boolean defaultLightWeightPopupEnabled,
             String expectedPopupClass) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -59,11 +57,11 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickOnMenu();
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Field getPopup = JPopupMenu.class.getDeclaredField("popup");
         getPopup.setAccessible(true);
@@ -87,7 +85,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 
 
@@ -99,7 +97,6 @@
             }
         });
 
-        Robot robot = new Robot();
         robot.setAutoDelay(100);
 
         robot.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
@@ -140,6 +137,7 @@
     }
 
     public static void main(String[] args) throws Exception {
+        robot = new Robot();
         testFrame(false, "javax.swing.PopupFactory$HeavyWeightPopup");
 
         testFrame(true, "javax.swing.PopupFactory$LightWeightPopup");
--- a/test/javax/swing/JPopupMenu/6827786/bug6827786.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JPopupMenu/6827786/bug6827786.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,7 +33,6 @@
 import java.awt.*;
 import java.awt.event.KeyEvent;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class bug6827786 {
 
@@ -41,7 +40,6 @@
     private static Component focusable;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -52,7 +50,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -61,7 +59,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         checkfocus();
 
         // select menu
@@ -72,17 +70,17 @@
         }
         // select submenu
         Util.hitKeys(robot, KeyEvent.VK_S);
-        toolkit.realSync();
+        robot.waitForIdle();
         // verify submenu is selected
         verify(1);
 
         Util.hitKeys(robot, KeyEvent.VK_S);
-        toolkit.realSync();
+        robot.waitForIdle();
         // verify last item is selected
         verify(2);
 
         Util.hitKeys(robot, KeyEvent.VK_S);
-        toolkit.realSync();
+        robot.waitForIdle();
         // selection should wrap to first item
         verify(0);
 
--- a/test/javax/swing/JPopupMenu/6987844/bug6987844.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JPopupMenu/6987844/bug6987844.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,8 +29,6 @@
  * @run main bug6987844
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.InputEvent;
@@ -40,7 +38,6 @@
     static JMenu menu2;
 
     public static void main(String... args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(200);
 
@@ -64,7 +61,7 @@
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         Point point1 = menu1.getLocationOnScreen();
         Point point2 = menu2.getLocationOnScreen();
 
@@ -79,7 +76,7 @@
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
         robot.mouseMove(point1.x + 1, point1.y + 1);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/JPopupMenu/7154841/bug7154841.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JPopupMenu/7154841/bug7154841.java	Fri Nov 21 16:11:03 2014 +0300
@@ -26,16 +26,17 @@
   @bug 7154841
   @summary JPopupMenu is overlapped by a Dock on Mac OS X
   @author Petr Pchelko
+  @library ../../../../lib/testlibrary
+  @build ExtendedRobot jdk.testlibrary.OSInfo
+  @run main bug7154841
  */
 
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import javax.swing.*;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionAdapter;
 import java.util.concurrent.atomic.AtomicReference;
+import jdk.testlibrary.OSInfo;
 
 public class bug7154841 {
 
@@ -71,20 +72,20 @@
         }
 
         try {
-            Robot r = new Robot();
+            ExtendedRobot r = new ExtendedRobot();
             r.setAutoDelay(100);
             r.setAutoWaitForIdle(true);
             r.mouseMove(0, 0);
 
             SwingUtilities.invokeAndWait(bug7154841::initAndShowUI);
 
-            sleep();
+            r.waitForIdle(200);
 
             SwingUtilities.invokeAndWait(() -> {
                 popupMenu.show(frame, frame.getX() + frame.getWidth() / 2, frame.getY() + frame.getHeight() / 2);
             });
 
-            sleep();
+            r.waitForIdle(200);
 
             int y = (int)screenBounds.get().getY() + (int)screenBounds.get().getHeight() - 10;
             int center = (int)(screenBounds.get().getX() + screenBounds.get().getWidth() / 2);
@@ -112,10 +113,4 @@
                 .getBounds();
     }
 
-    private static void sleep() {
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
-        try {
-            Thread.sleep(200);
-        } catch (InterruptedException ignored) { }
-    }
 }
--- a/test/javax/swing/JRadioButton/8033699/bug8033699.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JRadioButton/8033699/bug8033699.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,11 +35,9 @@
 import javax.swing.event.*;
 import java.awt.event.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 
 public class bug8033699 {
     private static Robot robot;
-    private static SunToolkit toolkit;
 
     private static JButton btnStart;
     private static ButtonGroup btnGrp;
@@ -61,7 +59,6 @@
         Thread.sleep(100);
 
         robot.setAutoDelay(100);
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         // tab key test grouped radio button
         runTest1();
@@ -284,7 +281,7 @@
     private static void hitKey(Robot robot, int keycode) {
         robot.keyPress(keycode);
         robot.keyRelease(keycode);
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 
     private static void hitKey(Robot robot, int mode, int keycode) {
@@ -292,6 +289,6 @@
         robot.keyPress(keycode);
         robot.keyRelease(mode);
         robot.keyRelease(keycode);
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 }
--- a/test/javax/swing/JRootPane/4670486/bug4670486.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JRootPane/4670486/bug4670486.java	Fri Nov 21 16:11:03 2014 +0300
@@ -24,7 +24,6 @@
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -101,7 +100,6 @@
     }
 
     public static void main(String[] args) throws Throwable {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(250);
 
@@ -120,7 +118,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Change the default button to
         // force a call to BasicRootPaneUI.updateDefaultButtonBindings()
@@ -131,14 +129,14 @@
         // effect.
         Util.hitMnemonics(robot, KeyEvent.VK_U);
         Util.hitKeys(robot, KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
 
         Util.hitMnemonics(robot, KeyEvent.VK_U);
         Util.hitKeys(robot, KeyEvent.VK_DOWN);
         Util.hitKeys(robot, KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkAction();
     }
--- a/test/javax/swing/JScrollBar/4708809/bug4708809.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JScrollBar/4708809/bug4708809.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,7 +32,6 @@
 import java.awt.*;
 import java.awt.Point;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
 
 public class bug4708809 {
 
@@ -42,7 +41,6 @@
     private static JScrollBar sbar;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(350);
 
@@ -53,7 +51,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -63,13 +61,13 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = getClickPoint(0.5, 0.5);
         robot.mouseMove(point.x, point.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -88,12 +86,12 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         point = getClickPoint(0.5, 0.2);
         robot.mouseMove(point.x, point.y);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!do_test || !passed) {
             throw new Exception("The scrollbar moved with incorrect direction");
@@ -131,4 +129,4 @@
         fr.setSize(200, 200);
         fr.setVisible(true);
     }
-}
\ No newline at end of file
+}
--- a/test/javax/swing/JScrollBar/6542335/bug6542335.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JScrollBar/6542335/bug6542335.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug6542335
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicScrollBarUI;
 import java.awt.*;
@@ -43,8 +41,6 @@
         final Robot robot = new Robot();
         robot.setAutoDelay(10);
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-
         final Rectangle[] thumbBounds = new Rectangle[1];
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -72,7 +68,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -86,7 +82,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/JScrollBar/7163696/Test7163696.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JScrollBar/7163696/Test7163696.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,12 +28,9 @@
  * @author Sergey Malenkov
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.InputEvent;
 
 import javax.swing.JFrame;
@@ -54,12 +51,11 @@
 
     private void test() throws Exception {
         Robot robot = new Robot();
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
             UIManager.setLookAndFeel(info.getClassName());
 
             SwingUtilities.invokeAndWait(this);
-            toolkit.realSync(); // after creation
+            robot.waitForIdle(); // after creation
             Thread.sleep(1000);
 
             Point point = this.bar.getLocation();
@@ -70,7 +66,7 @@
             robot.mousePress(InputEvent.BUTTON1_MASK);
             robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-            toolkit.realSync(); // before validation
+            robot.waitForIdle(); // before validation
             Thread.sleep(1000);
             SwingUtilities.invokeAndWait(this);
 
--- a/test/javax/swing/JScrollBar/bug4202954/bug4202954.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JScrollBar/bug4202954/bug4202954.java	Fri Nov 21 16:11:03 2014 +0300
@@ -22,8 +22,9 @@
  */
 /* @test
    @bug 4202954
+   @library ../../../../lib/testlibrary
    @library ../../regtesthelpers
-   @build Util
+   @build Util jdk.testlibrary.OSInfo
    @author Michael C. Albers
    @run main bug4202954
 */
@@ -31,11 +32,10 @@
 import java.awt.*;
 import java.awt.event.InputEvent;
 import javax.swing.*;
-import sun.awt.*;
+import jdk.testlibrary.OSInfo;
 
 public class bug4202954 {
     static JScrollPane buttonScrollPane;
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
     static Robot robot;
     public static void main(String[] args) throws Exception {
         if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
@@ -138,13 +138,17 @@
             }
         };
         Integer oldHValue = Util.invokeOnEDT(horizontalValue);
+        robot.waitForIdle();
         Integer oldVValue = Util.invokeOnEDT(verticalValue);
+        robot.waitForIdle();
 
         clickMouseOnComponent(scrollButton, buttons);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         int newHValue = Util.invokeOnEDT(horizontalValue);
+        robot.waitForIdle();
         int newVValue = Util.invokeOnEDT(verticalValue);
+        robot.waitForIdle();
 
         return (oldHValue != newHValue || oldVValue != newVValue) == expectScroll;
     }
--- a/test/javax/swing/JSlider/6348946/bug6348946.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JSlider/6348946/bug6348946.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,8 +29,6 @@
  * @author Mikhail Lapshin
 */
 
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.event.InputEvent;
 import javax.swing.*;
@@ -42,13 +40,16 @@
     private static JFrame frame;
 
     private static JPanel panel;
+    private static Robot robot;
 
     private static volatile boolean passed = false;
 
     public static void main(String[] args) throws Exception {
+        robot = new Robot();
+        robot.setAutoDelay(10);
+
         String lf = "javax.swing.plaf.metal.MetalLookAndFeel";
         UIManager.setLookAndFeel(lf);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         try {
             SwingUtilities.invokeAndWait(new Runnable() {
@@ -56,9 +57,9 @@
                     setupUI();
                 }
             });
-            toolkit.realSync();
+            robot.waitForIdle();
             clickOnSlider();
-            toolkit.realSync();
+            robot.waitForIdle();
             checkResult();
         } finally {
             stopEDT();
@@ -79,9 +80,6 @@
     }
 
     private static void clickOnSlider() throws Exception {
-        Robot robot = new Robot();
-        robot.setAutoDelay(10);
-
         Rectangle rect = getPanelRectangle();
 
         double clickX = rect.getX() + rect.getWidth() / 4;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JSlider/6401380/bug6401380.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ *
+ * 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 6401380
+   @summary JSlider - mouse click ont the left side of the knob is ignored.
+   @library ../../../../lib/testlibrary
+   @build ExtendedRobot
+   @author Alexander Potochkin
+   @run main bug6401380
+*/
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicSliderUI;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6401380 extends JFrame {
+    private static JSlider slider;
+
+    public bug6401380() {
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        slider = new JSlider();
+        slider.setMajorTickSpacing(0);
+        slider.setMaximum(50);
+        slider.setMinorTickSpacing(10);
+        slider.setPaintLabels(true);
+        slider.setPaintTicks(true);
+        slider.setSnapToTicks(true);
+
+        // MetalSliderUI overrides scrollDueToClickInTrack() method
+        // so this test doens't work for Metal
+        slider.setUI(new BasicSliderUI(slider));
+
+        add(slider);
+        setSize(200, 200);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(10);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                new bug6401380().setVisible(true);
+            }
+        });
+        robot.waitForIdle();
+
+        Point l = slider.getLocationOnScreen();
+        robot.glide(0, 0, l.x + slider.getWidth() / 2, l.y + slider.getHeight() / 2);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        robot.waitForIdle();
+
+        if (slider.getValue() == slider.getMaximum()) {
+            throw new RuntimeException("Slider value unchanged");
+        }
+    }
+}
--- a/test/javax/swing/JSlider/6848475/bug6848475.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JSlider/6848475/bug6848475.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
  * @run main bug6848475
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.SliderUI;
 import javax.swing.plaf.basic.BasicSliderUI;
@@ -47,7 +45,6 @@
     private static int thumbRectX;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         robot = new Robot();
         robot.setAutoDelay(100);
@@ -70,7 +67,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -80,7 +77,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -95,7 +92,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/JSpinner/4973721/bug4973721.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JSpinner/4973721/bug4973721.java	Fri Nov 21 16:11:03 2014 +0300
@@ -30,21 +30,18 @@
 */
 
 import java.awt.Robot;
-import java.awt.Toolkit;
 import javax.swing.event.ChangeListener;
 import javax.swing.event.ChangeEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.FocusListener;
 import java.awt.event.FocusEvent;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class bug4973721 implements ChangeListener, FocusListener {
     static volatile boolean bStateChanged = false;
     static volatile boolean bFocusGained = false;
     static JSpinner spinner;
     static final Object listener = new bug4973721();
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
     public void focusLost(FocusEvent e) {}
 
@@ -100,7 +97,7 @@
         robot.setAutoDelay(50);
 
         Util.hitKeys(robot, KeyEvent.VK_UP);
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         if (!bStateChanged) {
@@ -110,7 +107,7 @@
         bStateChanged = false;
 
         Util.hitKeys(robot, KeyEvent.VK_DOWN);
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         if (!bStateChanged) {
--- a/test/javax/swing/JSpinner/5012888/bug5012888.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JSpinner/5012888/bug5012888.java	Fri Nov 21 16:11:03 2014 +0300
@@ -43,10 +43,10 @@
       pane.add(spinner2, BorderLayout.SOUTH);
     }
     public void doTest() throws Exception {
-        ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        Robot robot = new Robot();
+        robot.waitForIdle();
         Point p = spinner2.getLocationOnScreen();
         Rectangle rect = spinner2.getBounds();
-        Robot robot = new Robot();
         robot.mouseMove(p.x+rect.width-5, p.y+5);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         Thread.sleep(1000);
--- a/test/javax/swing/JSplitPane/4885629/bug4885629.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JSplitPane/4885629/bug4885629.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
  * @author Andrey Pikalev
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
@@ -91,9 +89,8 @@
             }
         });
 
-        ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
-
         final Robot robot = new Robot();
+        robot.waitForIdle();
         robot.delay(1000);
 
         SwingUtilities.invokeAndWait(new Runnable() {
--- a/test/javax/swing/JTabbedPane/4361477/bug4361477.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTabbedPane/4361477/bug4361477.java	Fri Nov 21 16:11:03 2014 +0300
@@ -25,7 +25,6 @@
 import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.event.*;
-import sun.awt.SunToolkit;
 
 /*
  * @test
@@ -42,7 +41,6 @@
 
     public static void main(String args[]) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -54,7 +52,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
--- a/test/javax/swing/JTabbedPane/4624207/bug4624207.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTabbedPane/4624207/bug4624207.java	Fri Nov 21 16:11:03 2014 +0300
@@ -26,8 +26,9 @@
  * @bug 4624207
  * @summary JTabbedPane mnemonics don't work from outside the tabbed pane
  * @author Oleg Mokhovikov
+ * @library ../../../../lib/testlibrary
  * @library ../../regtesthelpers
- * @build Util
+ * @build Util jdk.testlibrary.OSInfo
  * @run main bug4624207
  */
 import javax.swing.*;
@@ -38,8 +39,7 @@
 import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
 
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
 
 public class bug4624207 implements ChangeListener, FocusListener {
 
@@ -65,7 +65,6 @@
     }
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -76,7 +75,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -85,7 +84,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!focusGained) {
             throw new RuntimeException("Couldn't gain focus for text field");
@@ -99,7 +98,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
@@ -107,7 +106,7 @@
             Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!stateChanged || tab.getSelectedIndex() != 1) {
             throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
--- a/test/javax/swing/JTabbedPane/6495408/bug6495408.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTabbedPane/6495408/bug6495408.java	Fri Nov 21 16:11:03 2014 +0300
@@ -23,7 +23,6 @@
 
 import javax.swing.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 /*
  * @test
  * @bug 6495408
@@ -37,7 +36,6 @@
     static JTabbedPane tabbedPane;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         final Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -56,7 +54,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         final Rectangle d = new Rectangle();
         final Point p = new Point();
--- a/test/javax/swing/JTabbedPane/7161568/bug7161568.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTabbedPane/7161568/bug7161568.java	Fri Nov 21 16:11:03 2014 +0300
@@ -23,7 +23,6 @@
 import java.awt.*;
 import javax.swing.*;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -40,7 +39,6 @@
     public static void main(String[] args) throws Exception {
         UIManager.put("TabbedPane.selectionFollowsFocus", Boolean.FALSE);
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -52,7 +50,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -62,12 +60,12 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         for (int i = 0; i < N; i++) {
             robot.keyPress(KeyEvent.VK_LEFT);
             robot.keyRelease(KeyEvent.VK_LEFT);
-            toolkit.realSync();
+            robot.waitForIdle();
         }
     }
 
--- a/test/javax/swing/JTable/4220171/bug4220171.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTable/4220171/bug4220171.java	Fri Nov 21 16:11:03 2014 +0300
@@ -34,12 +34,10 @@
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import javax.swing.*;
 import javax.swing.border.LineBorder;
-import sun.awt.SunToolkit;
 
 public class bug4220171 {
 
@@ -47,7 +45,6 @@
 
     public static void main(String args[]) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -58,26 +55,26 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickMouse(robot, 0, 0);
         Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkCell(0, 0);
 
         clickMouse(robot, 0, 1);
         Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkCell(0, 1);
 
         clickMouse(robot, 1, 0);
         Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkCell(1, 0);
 
         clickMouse(robot, 1, 1);
         Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkCell(1, 1);
     }
 
--- a/test/javax/swing/JTable/6263446/bug6263446.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTable/6263446/bug6263446.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,7 +32,6 @@
 import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.table.*;
-import sun.awt.SunToolkit;
 
 public class bug6263446 {
 
@@ -43,7 +42,6 @@
     private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -55,63 +53,63 @@
         });
 
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = getClickPoint();
         robot.mouseMove(point.x, point.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         click(1);
-        toolkit.realSync();
+        robot.waitForIdle();
         assertEditing(false);
 
         click(2);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(null);
 
         click(3);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(FIRST);
 
 
         click(4);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(ALL);
 
         setClickCountToStart(1);
 
         click(1);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(null);
 
         click(2);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(FIRST);
 
         click(3);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(ALL);
 
         setClickCountToStart(3);
 
         click(1);
-        toolkit.realSync();
+        robot.waitForIdle();
         assertEditing(false);
 
         click(2);
-        toolkit.realSync();
+        robot.waitForIdle();
         assertEditing(false);
 
         click(3);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(null);
 
         click(4);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(FIRST);
 
         click(5);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(ALL);
 
 
@@ -123,11 +121,11 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         assertEditing(true);
 
         click(2);
-        toolkit.realSync();
+        robot.waitForIdle();
         checkSelectedText(FIRST);
 
     }
--- a/test/javax/swing/JTable/6777378/bug6777378.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTable/6777378/bug6777378.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug6777378
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.JTableHeader;
@@ -43,7 +41,6 @@
     private static JTableHeader header;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(20);
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -78,7 +75,7 @@
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         Point point = header.getLocationOnScreen();
         robot.mouseMove(point.x + 20, point.y + 50);
         robot.mouseMove(point.x + 30, point.y + 50);
--- a/test/javax/swing/JTable/7055065/bug7055065.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTable/7055065/bug7055065.java	Fri Nov 21 16:11:03 2014 +0300
@@ -38,7 +38,6 @@
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import javax.swing.JFrame;
@@ -49,7 +48,6 @@
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableModel;
 import javax.swing.table.TableRowSorter;
-import sun.awt.SunToolkit;
 import java.util.concurrent.Callable;
 
 public class bug7055065 {
@@ -57,7 +55,6 @@
     private static JTable table;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -67,15 +64,15 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         clickCell(robot, 1, 1);
         Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
                 KeyEvent.VK_BACK_SPACE);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         clickColumnHeader(robot, 1);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         clickColumnHeader(robot, 1);
     }
 
--- a/test/javax/swing/JTable/7068740/bug7068740.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTable/7068740/bug7068740.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug7068740
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.LayerUI;
 import javax.swing.plaf.metal.MetalLookAndFeel;
@@ -43,7 +41,6 @@
 
     private static Robot robot = null;
     private static JTable table = null;
-    private static SunToolkit toolkit = null;
 
     bug7068740() {
         super();
@@ -83,10 +80,6 @@
                 robot.setAutoDelay(50);
             }
 
-            if (toolkit == null) {
-                toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-            }
-
             SwingUtilities.invokeAndWait(new Runnable() {
                 @Override
                 public void run() {
@@ -118,11 +111,11 @@
     }
 
     private static void doTest() throws Exception {
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(KeyEvent.VK_PAGE_DOWN);
         robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (getSelectedRow() != 19) {
             throw new RuntimeException("Test failed");
@@ -130,7 +123,7 @@
 
         robot.keyPress(KeyEvent.VK_PAGE_UP);
         robot.keyRelease(KeyEvent.VK_PAGE_UP);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (getSelectedRow() != 0) {
             throw new RuntimeException("Test failed");
         }
--- a/test/javax/swing/JTableHeader/6884066/bug6884066.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTableHeader/6884066/bug6884066.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug6884066
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.table.JTableHeader;
 import javax.swing.table.TableColumnModel;
@@ -46,7 +44,6 @@
 
         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(20);
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -62,7 +59,7 @@
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         Point point = header.getLocationOnScreen();
         robot.mouseMove(point.x + 3, point.y + 3);
         robot.mousePress(InputEvent.BUTTON1_MASK);
--- a/test/javax/swing/JTableHeader/6889007/bug6889007.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTableHeader/6889007/bug6889007.java	Fri Nov 21 16:11:03 2014 +0300
@@ -27,8 +27,6 @@
    @author Alexander Potochkin
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicTableHeaderUI;
 import javax.swing.table.JTableHeader;
@@ -37,7 +35,6 @@
 public class bug6889007 {
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(20);
 
@@ -59,7 +56,7 @@
                 frame.setVisible(true);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
         Point point = frame.getLocationOnScreen();
         int shift = 10;
         int x = point.x;
@@ -67,7 +64,7 @@
         for(int i = -shift; i < frame.getWidth() + 2*shift; i++) {
             robot.mouseMove(x++, y);
         }
-        toolkit.realSync();
+        robot.waitForIdle();
         // 9 is a magic test number
         if (MyTableHeaderUI.getTestValue() != 9) {
             throw new RuntimeException("Unexpected test number "
--- a/test/javax/swing/JTextArea/4697612/bug4697612.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTextArea/4697612/bug4697612.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,7 +35,6 @@
 import javax.swing.*;
 
 import javax.swing.text.BadLocationException;
-import sun.awt.SunToolkit;
 
 public class bug4697612 {
 
@@ -49,7 +48,6 @@
     private static JScrollPane scroller;
 
     public static void main(String[] args) throws Throwable {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(100);
 
@@ -61,7 +59,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -71,7 +69,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // 4697612: pressing PgDn + PgUp should not alter caret position
         Util.hitKeys(robot, KeyEvent.VK_HOME);
@@ -102,11 +100,11 @@
                     }
                 });
 
-                toolkit.realSync();
+                robot.waitForIdle();
 
                 Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
                 Util.hitKeys(robot, KeyEvent.VK_PAGE_UP);
-                toolkit.realSync();
+                robot.waitForIdle();
 
                 int pos = getTextCaretPosition();
                 if (pos0 != pos) {
@@ -126,11 +124,11 @@
             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END);
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         pos0 = getScrollerViewPosition();
         Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         int pos = getScrollerViewPosition();
 
@@ -187,6 +185,7 @@
     private static void createAndShowGUI() {
         frame = new JFrame();
         frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
+        frame.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
         text = new JTextArea();
--- a/test/javax/swing/JTextField/8036819/bug8036819.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTextField/8036819/bug8036819.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,7 +35,6 @@
 import javax.swing.event.*;
 import java.awt.event.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 import javax.accessibility.*;
 
 public class bug8036819 {
@@ -49,15 +48,14 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
 
         Robot robo = new Robot();
         robo.setAutoDelay(300);
+        robo.waitForIdle();
 
         // Using mnemonic key to focus on the textfield
         Util.hitMnemonics(robo, KeyEvent.VK_P);
-        toolkit.realSync();
+        robo.waitForIdle();
 
         if (!passed){
             throw new RuntimeException("Test failed.");
--- a/test/javax/swing/JToolBar/4247996/bug4247996.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JToolBar/4247996/bug4247996.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,7 +29,6 @@
  */
 import java.awt.*;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class bug4247996 {
 
@@ -38,7 +37,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -51,11 +49,11 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = getButtonCenter();
         robot.mouseMove(point.x, point.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         checkButtonsSize();
 
--- a/test/javax/swing/JToolTip/4846413/bug4846413.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JToolTip/4846413/bug4846413.java	Fri Nov 21 16:11:03 2014 +0300
@@ -37,7 +37,6 @@
 import javax.swing.*;
 import java.awt.event.*;
 import javax.swing.plaf.metal.MetalToolTipUI;
-import sun.awt.SunToolkit;
 
 public class bug4846413 {
 
@@ -46,7 +45,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -59,11 +57,11 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point movePoint = getButtonPoint();
         robot.mouseMove(movePoint.x, movePoint.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         long timeout = System.currentTimeMillis() + 9000;
         while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
--- a/test/javax/swing/JTree/4330357/bug4330357.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/4330357/bug4330357.java	Fri Nov 21 16:11:03 2014 +0300
@@ -34,7 +34,6 @@
 import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.tree.*;
-import sun.awt.SunToolkit;
 
 public class bug4330357 {
 
@@ -43,7 +42,6 @@
     private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -56,12 +54,12 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickMouse(getTreeRowClickPoint(1));
         Util.hitKeys(robot, KeyEvent.VK_F2);
         Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_C);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!hasComponent(JTextField.class)) {
             throw new RuntimeException("Cell editor is missed for path: color");
@@ -69,11 +67,11 @@
 
 
         clickMouse(getButtonClickPoint());
-        toolkit.realSync();
+        robot.waitForIdle();
 
         clickMouse(getTreeRowClickPoint(2));
         Util.hitKeys(robot, KeyEvent.VK_F2);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!hasComponent(JComboBox.class)) {
             throw new RuntimeException("Cell editor is missed for path: sports");
--- a/test/javax/swing/JTree/4908142/bug4908142.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/4908142/bug4908142.java	Fri Nov 21 16:11:03 2014 +0300
@@ -36,7 +36,6 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
 
 public class bug4908142 {
 
@@ -44,7 +43,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -55,7 +53,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -65,7 +63,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         robot.keyPress(KeyEvent.VK_A);
@@ -74,7 +72,7 @@
         robot.keyRelease(KeyEvent.VK_A);
         robot.keyPress(KeyEvent.VK_D);
         robot.keyRelease(KeyEvent.VK_D);
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         String sel = Util.invokeOnEDT(new Callable<String>() {
--- a/test/javax/swing/JTree/4927934/bug4927934.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/4927934/bug4927934.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,7 +33,6 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.lang.reflect.InvocationTargetException;
-import sun.awt.*;
 
 public class bug4927934 implements TreeSelectionListener, TreeExpansionListener, FocusListener {
 
@@ -73,8 +72,7 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         SwingUtilities.invokeLater(new Runnable() {
@@ -97,35 +95,35 @@
         // GO TO RIGHT
         selectionChanged = false;
         hitKey(KeyEvent.VK_RIGHT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!checkSelectionChanged(tree, 0)) {
             throw new RuntimeException("Root should be selected");
         }
 
         selectionChanged = false;
         hitKey(KeyEvent.VK_RIGHT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!checkSelectionChanged(tree, 1)) {
             throw new RuntimeException("Node should be selected");
         }
 
         treeExpanded = false;
         hitKey(KeyEvent.VK_RIGHT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!isTreeExpanded()) {
             throw new RuntimeException("Node should be expanded");
         }
 
         selectionChanged = false;
         hitKey(KeyEvent.VK_RIGHT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!checkSelectionChanged(tree, 2)) {
             throw new RuntimeException("Leaf1 should be selected");
         }
 
         selectionChanged = false;
         hitKey(KeyEvent.VK_RIGHT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!checkSelectionChanged(tree, 2)) {
             throw new RuntimeException("Leaf1 should be selected");
         }
@@ -133,7 +131,7 @@
         // GO TO LEFT
         selectionChanged = false;
         hitKey(KeyEvent.VK_LEFT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!checkSelectionChanged(tree, 1)) {
             throw new RuntimeException("Node should be selected");
         }
@@ -146,14 +144,14 @@
 
         selectionChanged = false;
         hitKey(KeyEvent.VK_LEFT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!checkSelectionChanged(tree, 0)) {
             throw new RuntimeException("Root should be selected");
         }
 
         treeCollapsed = false;
         hitKey(KeyEvent.VK_LEFT);
-        toolkit.realSync();
+        robot.waitForIdle();
         if (!isTreeCollapsed()) {
             throw new RuntimeException("Root should be collapsed");
         }
--- a/test/javax/swing/JTree/6263446/bug6263446.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/6263446/bug6263446.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,7 +33,6 @@
 import java.lang.reflect.Field;
 import javax.swing.*;
 import javax.swing.tree.*;
-import sun.awt.SunToolkit;
 
 public class bug6263446 {
 
@@ -42,10 +41,8 @@
     private static final String ALL = FIRST + " " + SECOND;
     private static JTree tree;
     private static Robot robot;
-    private static SunToolkit toolkit;
 
     public static void main(String[] args) throws Exception {
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -56,7 +53,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = getClickPoint();
         robot.mouseMove(point.x, point.y);
@@ -182,7 +179,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
     }
 
@@ -252,7 +249,7 @@
     }
 
     private static void assertEditingNoTreeLock(final boolean editing) throws Exception {
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
--- a/test/javax/swing/JTree/6505523/bug6505523.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/6505523/bug6505523.java	Fri Nov 21 16:11:03 2014 +0300
@@ -31,7 +31,6 @@
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.InputEvent;
 import javax.swing.JFrame;
 import javax.swing.JScrollPane;
@@ -42,14 +41,12 @@
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeNode;
-import sun.awt.SunToolkit;
 
 public class bug6505523 {
 
     private static JTree tree;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -61,14 +58,14 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = getRowPointToClick(2);
         robot.mouseMove(point.x, point.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
     }
 
@@ -129,4 +126,4 @@
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
     }
-}
\ No newline at end of file
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTree/6578666/bug6578666.java	Fri Nov 21 16:11:03 2014 +0300
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ *
+ * 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 6578666
+ * @summary REGRESSION: Exception occurs when updateUI for JTree is triggered by KeyEvent
+ * @run main bug6578666
+ * @author Alexander Potochkin
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+
+public class bug6578666 {
+
+    private static JTree tree;
+
+    private static void createGui() {
+        final JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        tree = new JTree();
+        frame.add(tree);
+
+        tree.addKeyListener(new KeyAdapter() {
+            public void keyPressed(KeyEvent e) {
+                tree.updateUI();
+            }
+        });
+
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+        Robot robot = new Robot();
+        robot.setAutoDelay(10);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                bug6578666.createGui();
+            }
+        });
+
+        robot.waitForIdle();
+
+        tree.requestFocus();
+        robot.waitForIdle();
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.waitForIdle();
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+
+    }
+}
--- a/test/javax/swing/JTree/8003400/Test8003400.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/8003400/Test8003400.java	Fri Nov 21 16:11:03 2014 +0300
@@ -26,17 +26,16 @@
  * @bug 8003400
  * @summary Tests that JTree shows the last row
  * @author Sergey Malenkov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
  * @run main/othervm Test8003400
  * @run main/othervm Test8003400 reverse
  * @run main/othervm Test8003400 system
  * @run main/othervm Test8003400 system reverse
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.Rectangle;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import java.util.Arrays;
 import java.util.Collections;
@@ -85,10 +84,12 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync(500);
-        new Robot().keyPress(KeyEvent.VK_END);
-        toolkit.realSync(500);
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.waitForIdle(500);
+        robot.keyPress(KeyEvent.VK_END);
+        robot.waitForIdle(500);
+        robot.keyRelease(KeyEvent.VK_END);
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/JTree/8004298/bug8004298.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/JTree/8004298/bug8004298.java	Fri Nov 21 16:11:03 2014 +0300
@@ -36,7 +36,6 @@
 import javax.swing.*;
 import javax.swing.tree.*;
 import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
 import com.sun.java.swing.plaf.windows.WindowsTreeUI;
 
@@ -47,7 +46,6 @@
     public static void main(String[] args) throws Exception {
         Robot robot = new Robot();
         robot.setAutoDelay(50);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         try {
             UIManager.setLookAndFeel(new WindowsLookAndFeel());
         } catch (javax.swing.UnsupportedLookAndFeelException ulafe) {
@@ -63,7 +61,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = Util.invokeOnEDT(new Callable<Point>() {
 
@@ -81,7 +79,7 @@
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
     }
 
--- a/test/javax/swing/Popup/TaskbarPositionTest.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/Popup/TaskbarPositionTest.java	Fri Nov 21 16:11:03 2014 +0300
@@ -259,7 +259,6 @@
 
     public static void main(String[] args) throws Throwable {
 
-        sun.awt.SunToolkit toolkit = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -275,7 +274,7 @@
         // 1 - menu
         Util.hitMnemonics(robot, KeyEvent.VK_1);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         isPopupOnScreen(menu1.getPopupMenu(), screenBounds);
 
         // 2 menu with sub menu
@@ -283,14 +282,14 @@
         robot.keyRelease(KeyEvent.VK_RIGHT);
         Util.hitMnemonics(robot, KeyEvent.VK_S);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         isPopupOnScreen(menu2.getPopupMenu(), screenBounds);
 
         robot.keyPress(KeyEvent.VK_ENTER);
         robot.keyRelease(KeyEvent.VK_ENTER);
 
         // Focus should go to non editable combo box
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(500);
 
         robot.keyPress(KeyEvent.VK_DOWN);
@@ -320,7 +319,7 @@
         robot.mousePress(InputEvent.BUTTON3_MASK);
         robot.mouseRelease(InputEvent.BUTTON3_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 test.setLocation(-30, 100);
@@ -334,7 +333,7 @@
         robot.keyPress(KeyEvent.VK_ESCAPE);
         robot.keyRelease(KeyEvent.VK_ESCAPE);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(500);
     }
 }
--- a/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java	Fri Nov 21 16:11:03 2014 +0300
@@ -31,7 +31,6 @@
 import java.awt.event.*;
 
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class NonOpaquePopupMenuTest extends JFrame {
 
@@ -53,7 +52,6 @@
     }
 
     public static void main(String[] args) throws Throwable {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(250);
 
@@ -65,14 +63,14 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point p = getMenuClickPoint();
         robot.mouseMove(p.x, p.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (isParentOpaque()) {
             throw new RuntimeException("Popup menu parent is opaque");
--- a/test/javax/swing/SwingUtilities/4917669/bug4917669.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/SwingUtilities/4917669/bug4917669.java	Fri Nov 21 16:11:03 2014 +0300
@@ -34,7 +34,6 @@
 import javax.swing.*;
 import java.awt.event.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 
 public class bug4917669 {
 
@@ -42,7 +41,6 @@
     private static JFrame mainFrame;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(500);
 
@@ -54,7 +52,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -64,10 +62,10 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_O);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!passed) {
             throw new RuntimeException("Action did not received by menu item.");
--- a/test/javax/swing/SwingUtilities/7146377/bug7146377.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/SwingUtilities/7146377/bug7146377.java	Fri Nov 21 16:11:03 2014 +0300
@@ -27,8 +27,6 @@
    @author Pavel Porvatov
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.InputEvent;
@@ -82,9 +80,9 @@
             }
         });
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // On Linux platforms realSync doesn't guaranties setSize completion
         Thread.sleep(1000);
@@ -95,7 +93,6 @@
             }
         });
 
-        Robot robot = new Robot();
 
         robot.setAutoDelay(200);
 
@@ -117,7 +114,7 @@
             robot.mouseRelease(button);
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/ToolTipManager/Test6256140.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/ToolTipManager/Test6256140.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,8 +29,6 @@
  * @run main Test6256140
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.KeyEvent;
@@ -46,14 +44,13 @@
 
         Robot robot = new Robot();
         robot.setAutoDelay(10);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 createAndShowGUI();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = ft.getLocationOnScreen();
         robot.mouseMove(point.x, point.y);
@@ -61,7 +58,7 @@
 
         robot.keyPress(KeyEvent.VK_A);
         robot.keyRelease(KeyEvent.VK_A);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!isTooltipShowning()) {
             throw new RuntimeException("Tooltip is not shown");
@@ -69,7 +66,7 @@
 
         robot.keyPress(KeyEvent.VK_ESCAPE);
         robot.keyRelease(KeyEvent.VK_ESCAPE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (isTooltipShowning()) {
             throw new RuntimeException("Tooltip must be hidden now");
@@ -81,7 +78,7 @@
 
         robot.keyPress(KeyEvent.VK_ESCAPE);
         robot.keyRelease(KeyEvent.VK_ESCAPE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!isTextEqual()) {
             throw new RuntimeException("FormattedTextField must cancel the updated value");
--- a/test/javax/swing/dnd/7171812/bug7171812.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/dnd/7171812/bug7171812.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main bug7171812
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.dnd.*;
 import java.awt.event.InputEvent;
@@ -45,7 +43,6 @@
      * @param args the command line arguments
      */
     public static void main(String[] args) throws Exception{
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
@@ -53,10 +50,10 @@
                 setupGUI();
             }
         });
-        toolkit.realSync();
 
         Robot robot = new Robot();
         robot.setAutoDelay(10);
+        robot.waitForIdle();
         robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) {
--- a/test/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,14 +32,11 @@
 import java.awt.*;
 import javax.swing.*;
 
-import sun.awt.SunToolkit;
-
 public class bug4251579 {
 
     private static JLabel htmlComponent;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         final Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -51,7 +48,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
--- a/test/javax/swing/plaf/basic/BasicMenuUI/4983388/bug4983388.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/plaf/basic/BasicMenuUI/4983388/bug4983388.java	Fri Nov 21 16:11:03 2014 +0300
@@ -30,7 +30,6 @@
    @run main bug4983388
 */
 
-import sun.awt.*;
 import java.awt.*;
 import javax.swing.*;
 import javax.swing.event.MenuListener;
@@ -64,7 +63,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         try {
             UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
         } catch (UnsupportedLookAndFeelException | ClassNotFoundException ex) {
@@ -78,9 +76,10 @@
         });
 
         Robot robot = new Robot();
+        robot.waitForIdle();
         Util.hitMnemonics(robot, KeyEvent.VK_F);
-
-        toolkit.realSync();
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (!bMenuSelected) {
             throw new RuntimeException("shortcuts on menus do not work");
--- a/test/javax/swing/plaf/basic/BasicTreeUI/8023474/bug8023474.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/plaf/basic/BasicTreeUI/8023474/bug8023474.java	Fri Nov 21 16:11:03 2014 +0300
@@ -29,8 +29,6 @@
  * @run main bug8023474
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.event.CellEditorListener;
 import javax.swing.tree.DefaultMutableTreeNode;
@@ -45,7 +43,6 @@
     private static JTree tree;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -55,14 +52,14 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point point = getRowPointToClick(1);
         robot.mouseMove(point.x, point.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Boolean result = (Boolean)tree.getCellEditor().getCellEditorValue();
         if (!result) {
--- a/test/javax/swing/plaf/synth/7158712/bug7158712.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/plaf/synth/7158712/bug7158712.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @author Pavel Porvatov
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicComboPopup;
 import javax.swing.plaf.synth.SynthLookAndFeel;
@@ -82,7 +80,7 @@
             }
         });
 
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         Point comboBoxLocation = Util.invokeOnEDT(new Callable<Point>() {
             @Override
--- a/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,13 +35,11 @@
 
 import javax.swing.*;
 import javax.swing.plaf.synth.*;
-import sun.awt.SunToolkit;
 
 public class bug6276188 extends JFrame {
 
     private static JButton button;
     private static Point p;
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
     public static void main(String[] args) throws Throwable {
         SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
@@ -67,7 +65,7 @@
 
         robot.mouseMove(p.x , p.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
         robot.delay(1000);
 
         Color color = robot.getPixelColor(p.x, p.y);
--- a/test/javax/swing/plaf/windows/WindowsRootPaneUI/WrongAltProcessing/WrongAltProcessing.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/plaf/windows/WindowsRootPaneUI/WrongAltProcessing/WrongAltProcessing.java	Fri Nov 21 16:11:03 2014 +0300
@@ -28,8 +28,6 @@
    @run main WrongAltProcessing
 */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
@@ -56,7 +54,7 @@
                 createWindows();
             }
         });
-        sync();
+        robot.waitForIdle();
         initRobot();
         runScript();
         SwingUtilities.invokeLater(new Runnable() {
@@ -75,11 +73,6 @@
         }
     }
 
-    public static void sync() {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
-    }
-
     public static void initRobot() throws AWTException {
         robot = new Robot();
         robot.setAutoDelay(100);
@@ -101,7 +94,7 @@
         robot.keyPress(KeyEvent.VK_ALT);
         robot.keyRelease(KeyEvent.VK_ALT);
         clickWindowsTitle(firstFrame);
-        sync();
+        robot.waitForIdle();
     }
 
     private static void pressTab() {
--- a/test/javax/swing/text/AbstractDocument/6968363/Test6968363.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/AbstractDocument/6968363/Test6968363.java	Fri Nov 21 16:11:03 2014 +0300
@@ -20,8 +20,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-import sun.awt.SunToolkit;
-
 import java.awt.Robot;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
@@ -47,17 +45,22 @@
  * @bug 6968363
  * @summary Ensures that a custom document may not extend AbstractDocument
  * @author Sergey Malenkov
+ * @library ../../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main Test6968363
  */
 public class Test6968363 implements Runnable, Thread.UncaughtExceptionHandler {
     private JFrame frame;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) getDefaultToolkit();
         Runnable task = new Test6968363();
         invokeAndWait(task);
-        toolkit.realSync(100);
-        new Robot().keyPress(VK_LEFT);
-        toolkit.realSync(100);
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.waitForIdle(100);
+        robot.keyPress(VK_LEFT);
+        robot.waitForIdle(100);
+        robot.keyRelease(VK_LEFT);
+        robot.waitForIdle(100);
         invokeAndWait(task);
     }
 
--- a/test/javax/swing/text/CSSBorder/6796710/bug6796710.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/CSSBorder/6796710/bug6796710.java	Fri Nov 21 16:11:03 2014 +0300
@@ -34,7 +34,6 @@
 import java.awt.*;
 import java.awt.image.BufferedImage;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class bug6796710 {
     // The page is inlined because we want to be sure that the JEditorPane filled synchronously
@@ -95,7 +94,7 @@
             }
         });
 
-        ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         // This delay should be added for MacOSX, realSync is not enough
         Thread.sleep(1000);
@@ -109,7 +108,7 @@
             }
         });
 
-        ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         // On Linux platforms realSync doesn't guaranties setSize completion
         Thread.sleep(1000);
--- a/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,19 +33,16 @@
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class bug4278839 extends JFrame {
 
     private static boolean passed = true;
     private static JTextArea area;
     private static Robot robo;
-    private static SunToolkit toolkit;
 
     public static void main(String[] args) {
         try {
 
-            toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
             robo = new Robot();
             robo.setAutoDelay(100);
 
@@ -56,10 +53,10 @@
                 }
             });
 
-            toolkit.realSync();
+            robo.waitForIdle();
 
             clickMouse();
-            toolkit.realSync();
+            robo.waitForIdle();
 
 
             if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
@@ -67,7 +64,7 @@
             } else {
                 Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME);
             }
-            toolkit.realSync();
+            robo.waitForIdle();
 
             passed &= moveCaret(true) == 1;
             passed &= moveCaret(true) == 5;
@@ -97,7 +94,7 @@
     private static int moveCaret(boolean right) throws Exception {
         Util.hitKeys(robo, getCtrlKey(),
                 right ? KeyEvent.VK_RIGHT : KeyEvent.VK_LEFT);
-        toolkit.realSync();
+        robo.waitForIdle();
 
         final int[] result = new int[1];
 
@@ -127,6 +124,7 @@
 
         robo.mouseMove(rect.x + rect.width / 2, rect.y + rect.width / 2);
         robo.mousePress(InputEvent.BUTTON1_MASK);
+        robo.mouseRelease(InputEvent.BUTTON1_MASK);
     }
 
     /**
--- a/test/javax/swing/text/JTextComponent/5074573/bug5074573.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/JTextComponent/5074573/bug5074573.java	Fri Nov 21 16:11:03 2014 +0300
@@ -35,7 +35,6 @@
 import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.text.*;
-import sun.awt.SunToolkit;
 
 public class bug5074573 {
 
@@ -60,11 +59,11 @@
     }
 
     static boolean test(final Class<? extends JTextComponent> textComponentClass) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoWaitForIdle(true);
         robot.setAutoDelay(50);
 
+
         SwingUtilities.invokeAndWait(new Runnable() {
 
             @Override
@@ -73,7 +72,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Remove selection from JTextField components for the Aqua Look & Feel
         if (textComponent instanceof JTextField && "Aqua".equals(UIManager.getLookAndFeel().getID())) {
@@ -87,14 +86,14 @@
                 }
             });
 
-            toolkit.realSync();
+            robot.waitForIdle();
         }
 
         robot.keyPress(getCtrlKey());
         robot.keyPress(KeyEvent.VK_BACK_SPACE);
         robot.keyRelease(KeyEvent.VK_BACK_SPACE);
         robot.keyRelease(getCtrlKey());
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -104,13 +103,13 @@
                 caret.setDot(0);
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(getCtrlKey());
         robot.keyPress(KeyEvent.VK_DELETE);
         robot.keyRelease(KeyEvent.VK_DELETE);
         robot.keyRelease(getCtrlKey());
-        toolkit.realSync();
+        robot.waitForIdle();
 
         return resultString.equals(getText());
     }
--- a/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java	Fri Nov 21 16:11:03 2014 +0300
@@ -33,13 +33,11 @@
 import javax.swing.*;
 import javax.swing.event.*;
 import javax.swing.text.*;
-import sun.awt.SunToolkit;
 
 public class bug4506788 extends JApplet {
 
     private volatile boolean passed = false;
     private JEditorPane jep;
-    private SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
     @Override
     public void init() {
@@ -65,7 +63,7 @@
             throw new RuntimeException("Robot could not be created");
         }
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point p;
         try {
@@ -78,6 +76,8 @@
         robot.mouseMove(p.x, p.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.keyPress(KeyEvent.VK_HOME);
+        robot.keyRelease(KeyEvent.VK_HOME);
         robot.keyPress(KeyEvent.VK_RIGHT);
         robot.keyRelease(KeyEvent.VK_RIGHT);
         robot.keyPress(KeyEvent.VK_X);
@@ -85,7 +85,7 @@
         robot.keyPress(KeyEvent.VK_RIGHT);
         robot.keyRelease(KeyEvent.VK_RIGHT);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!passed) {
             throw new RuntimeException("Test failed.");
--- a/test/javax/swing/text/View/8014863/bug8014863.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/View/8014863/bug8014863.java	Fri Nov 21 16:11:03 2014 +0300
@@ -32,8 +32,6 @@
  * @run main bug8014863
  */
 
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.text.GlyphView;
 import javax.swing.text.View;
@@ -49,7 +47,6 @@
     private static JEditorPane editorPane;
     private static JFrame frame;
     private static Robot robot;
-    private static SunToolkit toolkit;
 
     private static String text1 = "<p>one two qqqq <em>this is a test sentence</em> qqqq <em>pp</em> qqqq <em>pp</em> " +
             "qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq</p>";
@@ -59,14 +56,13 @@
     private static ArrayList<GlyphView> glyphViews;
 
     public static void main(String[] args) throws Exception {
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(50);
         glyphViews = new ArrayList<GlyphView>();
 
         createAndShowGUI(text1);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -80,10 +76,10 @@
 
         createAndShowGUI(text2);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_HOME);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_O);
         Util.hitKeys(robot, KeyEvent.VK_N);
@@ -94,7 +90,7 @@
         Util.hitKeys(robot, KeyEvent.VK_O);
         Util.hitKeys(robot, KeyEvent.VK_SPACE);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
--- a/test/javax/swing/text/html/CSS/4530474/bug4530474.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/html/CSS/4530474/bug4530474.java	Fri Nov 21 16:11:03 2014 +0300
@@ -34,8 +34,6 @@
 
 import java.io.*;
 
-import sun.awt.SunToolkit;
-
 public class bug4530474 {
 
     private static final Color TEST_COLOR = Color.BLUE;
@@ -43,7 +41,6 @@
 
     public static void main(String args[]) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         final Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -55,7 +52,8 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
+        robot.delay(500);
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
--- a/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java	Tue Dec 01 19:07:45 2015 +0300
+++ b/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java	Fri Nov 21 16:11:03 2014 +0300
@@ -37,7 +37,6 @@
 import javax.swing.text.Document;
 import javax.swing.text.BadLocationException;
 import java.awt.event.KeyEvent;
-import sun.awt.SunToolkit;
 
 public class bug5043626 {
 
@@ -45,7 +44,6 @@
     private static Robot robot;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -54,12 +52,12 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Util.hitKeys(robot, KeyEvent.VK_HOME);
         Util.hitKeys(robot, KeyEvent.VK_1);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         String test = getText();
 
@@ -70,7 +68,7 @@
         Util.hitKeys(robot, KeyEvent.VK_HOME);
         Util.hitKeys(robot, KeyEvent.VK_2);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         test = getText();