8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
authoryan
Fri, 05 Dec 2014 14:55:08 +0300
changeset 28087 622b2f420bc3
parent 28086 8f695682f781
child 28088 aa73c5bef23b
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2 Reviewed-by: serb, alexsch
jdk/test/java/awt/Choice/DragMouseOutAndRelease/DragMouseOutAndRelease.java
jdk/test/java/awt/Choice/GetSizeTest/GetSizeTest.java
jdk/test/java/awt/Choice/GrabLockTest/GrabLockTest.java
jdk/test/java/awt/Choice/PopupPosTest/PopupPosTest.html
jdk/test/java/awt/Choice/PopupPosTest/PopupPosTest.java
jdk/test/java/awt/Choice/ResizeAutoClosesChoice/ResizeAutoClosesChoice.java
jdk/test/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.html
jdk/test/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.java
jdk/test/java/awt/Choice/UnfocusableCB_ERR/UnfocusableCB_ERR.java
jdk/test/java/awt/Component/7097771/bug7097771.java
jdk/test/java/awt/Component/F10TopToplevel/F10TopToplevel.java
jdk/test/java/awt/Component/NativeInLightShow/NativeInLightShow.java
jdk/test/java/awt/FileDialog/ISCthrownByFileListTest/ISCthrownByFileListTest.java
jdk/test/java/awt/Focus/6378278/InputVerifierTest.java
jdk/test/java/awt/Focus/6382144/EndlessLoopTest.java
jdk/test/java/awt/Focus/6401036/InputVerifierTest2.java
jdk/test/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.html
jdk/test/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.java
jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html
jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.java
jdk/test/java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java
jdk/test/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.html
jdk/test/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.java
jdk/test/java/awt/Focus/KeyEventForBadFocusOwnerTest/KeyEventForBadFocusOwnerTest.java
jdk/test/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.html
jdk/test/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.java
jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.html
jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java
jdk/test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java
jdk/test/java/awt/Frame/GetBoundsResizeTest/GetBoundsResizeTest.java
jdk/test/java/awt/FullScreen/8013581/bug8013581.java
jdk/test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java
jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.html
jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.java
jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.html
jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.java
jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java
jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogTest/EnqueueWithDialogTest.java
jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/FreezeTest/FreezeTest.java
jdk/test/java/awt/List/ActionAfterRemove/ActionAfterRemove.java
jdk/test/java/awt/List/EmptyListEventTest/EmptyListEventTest.java
jdk/test/java/awt/List/KeyEventsTest/KeyEventsTest.html
jdk/test/java/awt/List/KeyEventsTest/KeyEventsTest.java
jdk/test/java/awt/List/NofocusListDblClickTest/NofocusListDblClickTest.java
jdk/test/java/awt/List/ScrollOutside/ScrollOut.java
jdk/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java
jdk/test/java/awt/MenuBar/8007006/bug8007006.java
jdk/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java
jdk/test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java
jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java
jdk/test/java/awt/Modal/ModalDialogOrderingTest/ModalDialogOrderingTest.java
jdk/test/java/awt/Modal/ModalInternalFrameTest/ModalInternalFrameTest.java
jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java
jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java
jdk/test/java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java
jdk/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java
jdk/test/java/awt/Multiscreen/MouseEventTest/MouseEventTest.java
jdk/test/java/awt/Paint/PaintNativeOnUpdate.java
jdk/test/java/awt/Robot/CtorTest/CtorTest.java
jdk/test/java/awt/TextArea/ScrollbarIntersectionTest/ScrollbarIntersectionTest.java
jdk/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java
jdk/test/java/awt/Toolkit/RealSync/Test.java
jdk/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java
jdk/test/java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java
jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java
jdk/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java
jdk/test/java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java
jdk/test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java
jdk/test/java/awt/event/KeyEvent/8020209/bug8020209.java
jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java
jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java
jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java
jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java
jdk/test/java/awt/event/KeyEvent/KeyChar/KeyCharTest.java
jdk/test/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java
jdk/test/java/awt/event/MouseWheelEvent/DisabledComponent/DisabledComponent.java
jdk/test/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java
jdk/test/java/awt/grab/MenuDragEvents/MenuDragEvents.html
jdk/test/java/awt/grab/MenuDragEvents/MenuDragEvents.java
jdk/test/java/awt/regtesthelpers/Util.java
jdk/test/java/awt/regtesthelpers/UtilInternal.java
jdk/test/javax/swing/JLabel/6596966/bug6596966.java
jdk/test/javax/swing/regtesthelpers/Util.java
jdk/test/sun/awt/dnd/8024061/bug8024061.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/DragMouseOutAndRelease/DragMouseOutAndRelease.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,421 @@
+/*
+ * 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 6322625
+  @summary REG:Choice does not trigger MouseReleased when dragging and releasing the mouse outside choice, XAWT
+  @author andrei.dmitriev area=awt.choice
+  @run main DragMouseOutAndRelease
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class DragMouseOutAndRelease
+{
+    static Frame frame = new Frame("Test Frame");
+    static Choice choice1 = new Choice();
+    static Robot robot;
+    static Point pt;
+    static volatile boolean mousePressed = false;
+    static volatile boolean mouseReleased = false;
+
+    private static void init()
+    {
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test, simply wait until it is done.",
+            "The result (passed or failed) will be shown in the",
+            "message window below."
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        frame.setLayout (new FlowLayout ());
+        for (int i = 1; i<10;i++){
+            choice1.add("item "+i);
+        }
+        frame.add(choice1);
+
+        choice1.addMouseListener(new MouseAdapter() {
+                public void mousePressed(MouseEvent me) {
+                    mousePressed = true;
+                    System.out.println(me);
+                }
+                public void mouseReleased(MouseEvent me) {
+                    mouseReleased = true;
+                    System.out.println(me);
+                }
+            });
+
+        frame.pack();
+        frame.setVisible(true);
+        frame.validate();
+
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(50);
+            robot.waitForIdle();
+            testMouseDrag();
+        } catch (Throwable e) {
+            new RuntimeException("Test failed. Exception thrown: "+e);
+        }
+        DragMouseOutAndRelease.pass();
+    }//End  init()
+
+    public static void testMouseDrag(){
+        mousePressed = false;
+        mouseReleased = false;
+
+        pt = choice1.getLocationOnScreen();
+        robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + choice1.getHeight()/2);
+        robot.waitForIdle();
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+
+
+        //move mouse outside Choice
+        robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y - choice1.getHeight());
+        robot.waitForIdle();
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+
+        if (!mousePressed || !mouseReleased)
+        {
+            System.out.println("ERROR: "+ mousePressed+","+mouseReleased);
+            // close the choice
+            robot.keyPress(KeyEvent.VK_ESCAPE);
+            robot.keyRelease(KeyEvent.VK_ESCAPE);
+            robot.waitForIdle();
+            DragMouseOutAndRelease.fail("Test failed. Choice should generate PRESSED, RELEASED events outside if pressed on Choice ");
+        } else{
+            // close the choice
+            robot.keyPress(KeyEvent.VK_ESCAPE);
+            robot.keyRelease(KeyEvent.VK_ESCAPE);
+            robot.waitForIdle();
+            System.out.println("Choice did generated PRESSED and RELEASED after Drag outside the Choice ");
+        }
+    }
+
+
+
+    /*****************************************************
+     * Standard Test Machinery Section
+     * DO NOT modify anything in this section -- it's a
+     * standard chunk of code which has all of the
+     * synchronisation necessary for the test harness.
+     * By keeping it the same in all tests, it is easier
+     * to read and understand someone else's test, as
+     * well as insuring that all tests behave correctly
+     * with the test harness.
+     * There is a section following this for test-
+     * classes
+     ******************************************************/
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+
+    }//main
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        Sysout.println( "The test passed." );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }//pass()
+
+    public static synchronized void fail()
+    {
+        //test writer didn't specify why test failed, so give generic
+        fail( "it just plain failed! :-)" );
+    }
+
+    public static synchronized void fail( String whyFailed )
+    {
+        Sysout.println( "The test failed: " + whyFailed );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }//fail()
+
+}// class DragMouseOutAndRelease
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+//  them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         DragMouseOutAndRelease.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         DragMouseOutAndRelease.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+        System.out.println(messageIn);
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/GetSizeTest/GetSizeTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1999, 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 4255631
+  @summary Solaris: Size returned by Choice.getSize() does not match actual size
+  @author Andrei Dmitriev : area=Choice
+  run main GetSizeTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class GetSizeTest {
+
+    static String []s = {"Choice 1",
+                         "Choice 2",
+                         "unselected choices",
+                         "what choices do I have?",
+                         "Will I pick the same thing in the future?",
+                };
+    static boolean passed = false;
+    static Robot robot = null;
+
+    public static void main(String args[])
+    {
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(50);
+
+            Frame f = new Frame("choice test");
+
+            Panel p = new Panel();
+            p.setLayout(null);
+
+            Choice c = new Choice();
+            for (int i = 0; i < s.length; i++)
+                    c.addItem(s[i]);
+
+            c.addMouseListener(new MouseAdapter() {
+                public void mouseReleased(MouseEvent e) {
+                    System.err.println("Test passed");
+                    passed = true;
+                }
+            });
+
+            p.add(c);
+
+            f.add(p);
+
+            f.setSize(300, 300);
+
+            f.addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent we) {
+                    System.err.println("Test passed");
+                    passed = true;
+                }
+            });
+
+            f.setVisible(true);
+
+            c.setSize(200, 200);
+            f.validate();
+
+            robot.waitForIdle();
+
+            Point pt = c.getLocationOnScreen();
+            robot.mouseMove(pt.x + c.getWidth() - 10, pt.y + c.getHeight() / 2);
+            robot.waitForIdle();
+            robot.mousePress(InputEvent.BUTTON2_MASK);
+            robot.mouseRelease(InputEvent.BUTTON2_MASK);
+            robot.waitForIdle();
+        } catch (Throwable e) {
+            if (robot == null){
+                throw new RuntimeException( "Test failed.Unable to initialize Robot "+e);
+            }
+            throw new RuntimeException( "Test failed due to thrown exception "+e);
+        }
+        if (!passed) {
+            throw new RuntimeException( "Timeout. Choice component size is not actual size." );
+        }
+        System.err.println("Test passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/GrabLockTest/GrabLockTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,110 @@
+/*
+ * 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 4800638
+  @summary Tests that Choice does not lock the Desktop
+  @run main GrabLockTest
+*/
+import java.awt.*;
+import java.awt.event.*;
+
+public class GrabLockTest
+{
+    public static void main (String args[])
+    {
+        Frame frame = new TestFrame();
+    }
+}
+
+class TestFrame extends Frame implements MouseListener {
+    public TestFrame() {
+        Choice choice = new Choice();
+        choice.addItem("Fist Item");
+        choice.addItem("Second Item");
+        add(choice,BorderLayout.NORTH);
+        Panel panel = new Panel();
+        panel.addMouseListener(this);
+        panel.setBackground(Color.RED);
+        add(panel);
+        setSize(200, 200);
+        setVisible(true);
+        toFront();
+
+        try {
+            Robot robot = new Robot();
+            robot.setAutoWaitForIdle(true);
+            robot.setAutoDelay(50);
+
+            robot.waitForIdle();
+
+            Point pt = choice.getLocationOnScreen();
+            robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/2,
+                pt.y + choice.getHeight()/2);
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.waitForIdle();
+            robot.mouseMove(pt.x + choice.getWidth()/2,
+                pt.y + choice.getHeight()*2);
+            robot.waitForIdle();
+            robot.mousePress(InputEvent.BUTTON2_MASK);
+            robot.waitForIdle();
+            Point pt1 = panel.getLocationOnScreen();
+            robot.mouseMove(pt1.x + panel.getWidth()/2,
+                pt1.y + panel.getHeight()/2);
+            robot.waitForIdle();
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+            robot.mouseRelease(InputEvent.BUTTON2_MASK);
+
+            robot.waitForIdle();
+
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.delay(30);
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+            robot.waitForIdle();
+            if (nPressed == 0) {
+                robot.keyPress(KeyEvent.VK_ESCAPE);
+                robot.keyRelease(KeyEvent.VK_ESCAPE);
+                throw new RuntimeException("GrabLockTest failed." + nPressed);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("The test was not completed.\n\n" + e);
+        }
+
+    }
+
+    public int nPressed = 0;
+
+    public void mouseClicked(MouseEvent e) {
+    }
+
+    public void mousePressed(MouseEvent e) {
+        nPressed++;
+        System.out.println("Pressed!");
+    }
+
+    public void mouseReleased(MouseEvent e) {
+    }
+
+    public void mouseEntered(MouseEvent e) {}
+    public void mouseExited(MouseEvent e) {}
+}// class TestFrame
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/PopupPosTest/PopupPosTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,46 @@
+<!--
+ Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ 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.
+-->
+
+<html>
+<!--  
+  @test
+  @bug 5044150
+  @summary Tests that pupup doesn't popdown if no space to display under 
+  @author ssi@sparc.spb.su
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run applet PopupPosTest.html
+  -->
+<head>
+<title> PopupPosTest </title>
+</head>
+<body>
+
+<h1>PopupPosTest<br>Bug ID: 5044150</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="PopupPosTest.class" WIDTH=350 HEIGHT=400></APPLET>
+</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/PopupPosTest/PopupPosTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 5044150
+  @summary Tests that pupup doesn't popdown if no space to display under
+  @author andrei.dmitriev area=awt.choice
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run applet PopupPosTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+import jdk.testlibrary.OSInfo;
+
+public class PopupPosTest extends Applet
+{
+    public void start ()
+    {
+        if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+            // On OS X, popup isn't under the mouse
+            return;
+        }
+        Frame frame = new TestFrame();
+    }
+}
+
+class TestFrame extends Frame implements ItemListener {
+    Robot robot;
+    Toolkit tk = Toolkit.getDefaultToolkit();
+    Choice choice = new Choice();
+    boolean indexChanged = false;
+    final static int INITIAL_ITEM = 99;
+    volatile boolean stateChanged;
+
+    public TestFrame() {
+        for (int i = 0; i < 100; i++) {
+             choice.addItem("Item Item Item " + i);
+        }
+        choice.addItemListener(this);
+
+        choice.select(INITIAL_ITEM);
+        choice.setFont(new Font("Courier", Font.BOLD + Font.ITALIC, 100));
+
+        add(choice, BorderLayout.CENTER);
+        Dimension screen = tk.getScreenSize();
+        setSize(screen.width - 10, screen.height - 70);
+        setVisible(true);
+        toFront();
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(50);
+            robot.waitForIdle();
+            // fix for 6175418. When we take "choice.getHeight()/2"
+            // divider 2 is not sufficiently big to hit into the
+            // small box Choice. We should use bigger divider to get
+            // smaller value choice.getHeight()/i. 4 is sufficient.
+            Point pt = choice.getLocationOnScreen();
+            // click on 1/4 of Choice's height
+            mouseMoveAndPressOnChoice(pt.x + choice.getWidth()/2,
+                              pt.y + choice.getHeight()/4);
+
+            // click on center of Choice's height
+            mouseMoveAndPressOnChoice(pt.x + choice.getWidth()/2,
+                              pt.y + choice.getHeight()/2);
+
+            // click on 3/4 of Choice's height
+            mouseMoveAndPressOnChoice(pt.x + choice.getWidth()/2,
+                              pt.y + choice.getHeight()*3/4);
+            // testing that ItemEvent doesn't generated on a simple
+            // mouse click when the dropdown appears under mouse : 6425067
+            stateChanged = false;
+            openChoice();
+            closeChoice();
+        } catch (Throwable e) {
+            throw new RuntimeException("The test was not completed.\n\n" + e);
+        }
+
+        if (!indexChanged){
+            throw new RuntimeException("Test failed. Another item wasn't selected.");
+        }
+
+        if(stateChanged){
+            throw new RuntimeException("Test failed. ItemEvent was generated on a simple mouse click when the dropdown appears under mouse");
+        }
+    }// start()
+
+    public void itemStateChanged(ItemEvent ie) {
+        System.out.println("choice.stateChanged = "+ ie);
+        stateChanged = true;
+    }
+
+    public void mouseMoveAndPressOnChoice(int x, int y){
+        openChoice();
+        robot.mouseMove(x, y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(30);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+        //should close choice after each test stage
+        closeChoice();
+        checkSelectedIndex();
+    }
+
+    public void openChoice(){
+        Point pt = choice.getLocationOnScreen();
+        robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/4,
+                        pt.y + choice.getHeight()/2);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(30);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+    }
+    public void closeChoice(){
+        robot.keyPress(KeyEvent.VK_ESCAPE);
+        robot.keyRelease(KeyEvent.VK_ESCAPE);
+        robot.waitForIdle();
+    }
+
+    public void checkSelectedIndex(){
+        if (choice.getSelectedIndex() != INITIAL_ITEM) {
+            System.out.println("choice.getSelectedIndex = "+ choice.getSelectedIndex());
+            indexChanged = true;
+        }
+    }
+}// class TestFrame
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/ResizeAutoClosesChoice/ResizeAutoClosesChoice.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,113 @@
+/*
+ * 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 6399679
+  @summary Choice is not invalidated when the frame gets resized programmatically when the drop-down is visible
+  @author andrei.dmitriev area=awt.choice
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run main ResizeAutoClosesChoice
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import jdk.testlibrary.OSInfo;
+
+public class ResizeAutoClosesChoice
+{
+    static Frame frame = new Frame("Test Frame");
+    static Choice choice1 = new Choice();
+    static Robot robot;
+    static Point pt;
+    static String passed = null;
+    static Button button = new Button("This button causes Frame to be resized on pack()");
+    public static void main(String args[]) throws Exception
+    {
+        if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+            System.out.println("Not for OS OX");
+            return;
+        }
+
+        choice1.setForeground(Color.red);
+        choice1.setBackground(Color.red);
+
+        frame.setLayout (new BorderLayout ());
+        for (int i = 1; i<10;i++){
+            choice1.add("item "+i);
+        }
+        frame.setSize(300, 300);
+        choice1.setLocation(50, 50);
+        choice1.setSize(70, 20);
+
+        button.setLocation(150, 100);
+        button.setSize(150, 20);
+        frame.add(choice1, BorderLayout.SOUTH);
+        frame.pack();
+
+        frame.validate();
+        frame.setVisible(true);
+
+        robot = new Robot();
+        robot.waitForIdle();
+        pt = choice1.getLocationOnScreen();
+        robot.mouseMove(pt.x + choice1.getWidth()/10*9, pt.y + choice1.getHeight()/2);
+        robot.waitForIdle();
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(1000);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        Color color = robot.getPixelColor(pt.x + choice1.getWidth()/2,
+                                          pt.y + 3 * choice1.getHeight());
+        //should take a color on the point on the choice's menu
+        System.out.println("Choice opened. Color got : "+color);
+        if ( !color.equals(Color.red) ){
+            passed = "Choice wasn't opened with the mouse";
+        }
+
+        Rectangle oldBounds = choice1.getBounds();
+        System.out.println("Choice's old bounds : "+oldBounds);
+
+        frame.add(button, BorderLayout.NORTH);
+        //            frame.setSize(500, 500);
+        frame.pack();
+        robot.waitForIdle();
+        System.out.println("Choice's new bounds : "+choice1.getBounds());
+
+        if (!choice1.getBounds().equals(oldBounds)){
+            pt = choice1.getLocationOnScreen();
+            color = robot.getPixelColor(pt.x + choice1.getWidth()/2,
+                                        pt.y + 3 * choice1.getHeight());
+            System.out.println("Choice opened. Color got : "+color);
+            if (color.equals(Color.red) ){
+                passed = "Choice wasn't closed when toplevel repacked.";
+            }
+        } else {
+            System.out.println("frame.pack didn't changed Choice's size - dropdown menu should remain the same. Test passed.");
+        }
+        if (passed != null){
+            throw new RuntimeException(passed);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,44 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--  
+  @test 1.2 01/02/10
+  @bug 4902933
+  @summary Test that selecting the current item sends an ItemEvent
+  @author bchristi : area= Choice
+  @run applet SelectCurrentItemTest.html
+  -->
+<head>
+<title>  </title>
+</head>
+<body>
+
+<h1>SelectCurrentItemTest<br>Bug ID: 9999999 XXX_CHANGE_THIS </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="SelectCurrentItemTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+/*
+  test 1.3 02/06/25
+  @bug 4902933
+  @summary Test that selecting the current item sends an ItemEvent
+  @author bchristi : area= Choice
+  @run applet SelectCurrentItemTest.html
+*/
+
+// Note there is no @ in front of test above.  This is so that the
+//  harness will not mistake this file as a test file.  It should
+//  only see the html file as a test file. (the harness runs all
+//  valid test files, so it would run this test twice if this file
+//  were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag.  Here, you
+//  should put which functional area the test falls in.  See the
+//  AWT-core home page -> test areas and/or -> AWT team  for a list of
+//  areas.
+// Note also the 'SelectCurrentItemTest.html' in the run tag.  This should
+//  be changed to the name of the test.
+
+
+/**
+ * SelectCurrentItemTest.java
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors.  (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems).  Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class SelectCurrentItemTest extends Applet implements ItemListener,
+ WindowListener, Runnable
+{
+    //Declare things used in the test, like buttons and labels here
+    Frame frame;
+    Choice theChoice;
+    Robot robot;
+
+    Object lock = new Object();
+    boolean passed = false;
+
+    public void init()
+    {
+        //Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+
+        this.setLayout (new BorderLayout ());
+
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test",
+            "simply wait until it is done"
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        frame = new Frame("SelectCurrentItemTest");
+        theChoice = new Choice();
+        for (int i = 0; i < 10; i++) {
+            theChoice.add(new String("Choice Item " + i));
+        }
+        theChoice.addItemListener(this);
+        frame.add(theChoice);
+        frame.addWindowListener(this);
+
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(500);
+        }
+        catch (AWTException e) {
+            throw new RuntimeException("Unable to create Robot.  Test fails.");
+        }
+
+    }//End  init()
+
+    public void start ()
+    {
+        //Get things going.  Request focus, set size, et cetera
+        setSize (200,200);
+        setVisible(true);
+        validate();
+
+        //What would normally go into main() will probably go here.
+        //Use System.out.println for diagnostic messages that you want
+        //to read after the test is done.
+        //Use Sysout.println for messages you want the tester to read.
+
+        frame.setLocation(1,20);
+        robot.mouseMove(10, 30);
+        frame.pack();
+        frame.setVisible(true);
+        synchronized(lock) {
+        try {
+        lock.wait(120000);
+        }
+        catch(InterruptedException e) {}
+        }
+        robot.waitForIdle();
+        if (!passed) {
+            throw new RuntimeException("TEST FAILED!");
+        }
+
+        // wait to make sure ItemEvent has been processed
+
+//        try {Thread.sleep(10000);} catch (InterruptedException e){}
+    }// start()
+
+    public void run() {
+        try {Thread.sleep(1000);} catch (InterruptedException e){}
+        // get loc of Choice on screen
+        Point loc = theChoice.getLocationOnScreen();
+        // get bounds of Choice
+        Dimension size = theChoice.getSize();
+        robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2);
+
+        robot.setAutoDelay(250);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        robot.setAutoDelay(1000);
+        robot.mouseMove(loc.x + size.width / 2, loc.y + size.height + size.height / 2);
+        robot.setAutoDelay(250);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+        synchronized(lock) {
+            lock.notify();
+        }
+    }
+
+    public void itemStateChanged(ItemEvent e) {
+        Sysout.println("ItemEvent received.  Test passes");
+        passed = true;
+    }
+
+    public void windowOpened(WindowEvent e) {
+        Sysout.println("windowActivated()");
+        Thread testThread = new Thread(this);
+        testThread.start();
+    }
+    public void windowActivated(WindowEvent e) {
+    }
+    public void windowDeactivated(WindowEvent e) {}
+    public void windowClosed(WindowEvent e) {}
+    public void windowClosing(WindowEvent e) {}
+    public void windowIconified(WindowEvent e) {}
+    public void windowDeiconified(WindowEvent e) {}
+
+}// class SelectCurrentItemTest
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setLocation(0, 400);
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        show();
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/UnfocusableCB_ERR/UnfocusableCB_ERR.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,421 @@
+/*
+ * 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 6390103
+  @summary Non-Focusable choice throws exception when selecting an item, Win32
+  @author andrei.dmitriev area=awt.choice
+  @run main UnfocusableCB_ERR
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class UnfocusableCB_ERR
+{
+    static final int delay = 100;
+    static Frame frame = new Frame("Test Frame");
+    static Choice choice1 = new Choice();
+    static Button button = new Button("Test");
+
+    static Robot robot;
+    static Point pt;
+    static String failed = "";
+
+    private static void init()
+    {
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test, simply wait until it is done.",
+            "The result (passed or failed) will be shown in the",
+            "message window below."
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                Thread.currentThread().setUncaughtExceptionHandler(
+                   new Thread.UncaughtExceptionHandler(){
+                       public void uncaughtException(Thread t, Throwable exc){
+                           failed = exc.toString();
+                       }
+                   });
+            }
+        });
+
+        frame.setLayout (new FlowLayout ());
+        for (int i = 1; i<10;i++){
+            choice1.add("item "+i);
+        }
+        frame.add(button);
+        frame.add(choice1);
+
+        choice1.setFocusable(false);
+
+        frame.pack();
+        frame.setVisible(true);
+        frame.validate();
+
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(50);
+            robot.waitForIdle();
+            testSpacePress();
+        } catch (Throwable e) {
+            UnfocusableCB_ERR.fail("Test failed. Exception thrown: "+e);
+        }
+        if (failed.equals("")){
+            UnfocusableCB_ERR.pass();
+        } else {
+            UnfocusableCB_ERR.fail("Test failed:");
+        }
+    }//End  init()
+
+    public static void testSpacePress(){
+
+        pt = choice1.getLocationOnScreen();
+        robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + choice1.getHeight()/2);
+        robot.waitForIdle();
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+
+        robot.waitForIdle();
+
+        //position mouse cursor over dropdown menu
+        robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + 2 * choice1.getHeight());
+        robot.waitForIdle();
+
+        //move mouse outside Choice
+        robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y - choice1.getHeight());
+        robot.waitForIdle();
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.waitForIdle();
+    }
+
+
+
+    /*****************************************************
+     * Standard Test Machinery Section
+     * DO NOT modify anything in this section -- it's a
+     * standard chunk of code which has all of the
+     * synchronisation necessary for the test harness.
+     * By keeping it the same in all tests, it is easier
+     * to read and understand someone else's test, as
+     * well as insuring that all tests behave correctly
+     * with the test harness.
+     * There is a section following this for test-
+     * classes
+     ******************************************************/
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+
+    }//main
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        Sysout.println( "The test passed." );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }//pass()
+
+    public static synchronized void fail()
+    {
+        //test writer didn't specify why test failed, so give generic
+        fail( "it just plain failed! :-)" );
+    }
+
+    public static synchronized void fail( String whyFailed )
+    {
+        Sysout.println( "The test failed: " + whyFailed );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }//fail()
+
+}// class UnfocusableCB_ERR
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+//  them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         UnfocusableCB_ERR.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         UnfocusableCB_ERR.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+        System.out.println(messageIn);
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- a/jdk/test/java/awt/Component/7097771/bug7097771.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Component/7097771/bug7097771.java	Fri Dec 05 14:55:08 2014 +0300
@@ -21,14 +21,12 @@
  * questions.
  */
 
-import sun.awt.SunToolkit;
 import test.java.awt.regtesthelpers.Util;
 
 import java.awt.AWTException;
 import java.awt.Button;
 import java.awt.Frame;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
@@ -53,13 +51,14 @@
         button.addActionListener(frame);
         frame.add(button);
         frame.setVisible(true);
-        sleep();
+        Robot robot = new Robot();
+        sleep(robot);
         frame.setEnabled(false);
         button.setEnabled(false);
         button.setEnabled(true);
-        sleep();
-        Util.clickOnComp(button, new Robot());
-        sleep();
+        sleep(robot);
+        Util.clickOnComp(button, robot);
+        sleep(robot);
         frame.dispose();
         if (action) {
             throw new RuntimeException("Button is not disabled.");
@@ -71,8 +70,8 @@
         action = true;
     }
 
-    private static void sleep() {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+    private static void sleep(Robot robot) {
+        robot.waitForIdle();
         try {
             Thread.sleep(1000);
         } catch (InterruptedException ignored) {
--- a/jdk/test/java/awt/Component/F10TopToplevel/F10TopToplevel.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Component/F10TopToplevel/F10TopToplevel.java	Fri Dec 05 14:55:08 2014 +0300
@@ -90,29 +90,26 @@
         Robot robot;
         try {
             robot = new Robot();
+            robot.setAutoDelay(5);
         } catch(AWTException e){
             throw new RuntimeException("cannot create robot.", e);
         }
-        ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
         robot.mouseMove(dialog.getLocationOnScreen().x + dialog.getWidth()/2,
                         dialog.getLocationOnScreen().y + dialog.getHeight()/2 );
-        robot.delay(5);
+        robot.waitForIdle();
         robot.mousePress(InputEvent.BUTTON1_MASK);
-        robot.delay(5);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        robot.delay(5);
+        robot.waitForIdle();
         robot.keyPress(KeyEvent.VK_F10);
-        robot.delay(5);
         robot.keyRelease(KeyEvent.VK_F10);
-        robot.delay(5);
 
         robot.delay(10);
         robot.keyPress(KeyEvent.VK_ENTER);
-        robot.delay(5);
+        robot.waitForIdle();
         robot.keyRelease(KeyEvent.VK_ENTER);
-        robot.delay(5);
 
-        ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         if(menuToggled) {
             throw new RuntimeException("Oops! Menu should not open.");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/NativeInLightShow/NativeInLightShow.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 1.0 04/05/20
+  @bug 4140484
+  @summary Heavyweight components inside invisible lightweight containers still show
+  @author Your Name: art@sparc.spb.su
+  @run main NativeInLightShow
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+
+// The test verifies that the mixing code correctly handles COMPONENT_SHOWN events
+// while the top-level container is invisible.
+
+public class NativeInLightShow
+{
+    //Declare things used in the test, like buttons and labels here
+    static boolean buttonPressed = false;
+    public static void main(String args[]) throws Exception {
+        Frame f = new Frame("Test");
+
+        Robot robot = null;
+        robot = new Robot();
+        robot.setAutoDelay(50);
+
+        Container c = new Container();
+        c.setLayout(new BorderLayout());
+        Button b = new Button("I'm should be visible!");
+        b.addActionListener(new ActionListener()
+        {
+            public void actionPerformed(ActionEvent e) {
+                System.out.println("Test PASSED");
+                buttonPressed = true;
+            }
+        });
+        c.add(b);
+
+        f.add(c);
+
+        f.pack();
+
+        c.setVisible(false);
+        c.setVisible(true);
+
+        // Wait for a while for COMPONENT_SHOW event to be dispatched
+        robot.waitForIdle();
+
+        f.setVisible(true);
+
+        robot.waitForIdle();
+
+        Point buttonLocation = b.getLocationOnScreen();
+
+        robot.mouseMove(buttonLocation.x + 5, buttonLocation.y + 5);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        // Wait for a while for ACTION event to be dispatched
+        robot.waitForIdle();
+        robot.delay(100);
+
+        if (!buttonPressed) {
+            System.out.println("Test FAILED");
+            throw new RuntimeException("Button was not pressed");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FileDialog/ISCthrownByFileListTest/ISCthrownByFileListTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 6304979
+  @summary REG: File Dialog throws ArrayIndexOutOfBounds Exception on XToolkit with b45
+  @author Dmitry Cherepanov: area=awt.filedialog
+  @run main/othervm -Dsun.awt.disableGtkFileDialogs=true ISCthrownByFileListTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.reflect.*;
+
+/*
+  Since the "sun.awt.exception.handler" property will be removed in a future release
+  this test will be rewritten using new future API. (<<< Done).
+  It's important that the bug 6304979 is reproducible if the bug 6299853 is reproducible.
+*/
+
+public class ISCthrownByFileListTest
+{
+    private static Frame frame = null;
+    private static FileDialog fd = null;
+
+    // The handler load the class and instantiate this class
+    // so the 'passed' variable is static
+    static boolean passed = true;
+
+    public static final void main(String args[]) {
+        // It's not true that the native file dialog will be focused on Motif & Windows
+        boolean isXToolkit = Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.XToolkit");
+        if (!isXToolkit){
+            return;
+        }
+
+        frame = new Frame("frame");
+        frame.setLayout (new FlowLayout ());
+        frame.setBounds(100, 100, 100, 100);
+        frame.setVisible(true);
+
+        fd = new FileDialog(frame, "file dialog", FileDialog.LOAD);
+
+        // In order to handle all uncaught exceptions in the EDT
+        final Thread.UncaughtExceptionHandler eh = new Thread.UncaughtExceptionHandler()
+        {
+            @Override
+            public void uncaughtException(Thread t, Throwable e)
+            {
+                e.printStackTrace();
+                ISCthrownByFileListTest.passed = false;
+            }
+        };
+
+        test();
+    }// start()
+
+    private static void test (){
+        Robot r;
+
+        try {
+            r = new Robot();
+        } catch(AWTException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+
+        r.delay(500);
+        new Thread(new Runnable() {
+                public void run() {
+                    // The bug 6299853 is reproducible only if the file list is not empty
+                    // since else the focus will be set to the directory list.
+                    // But the focus index of the directory list equals 0.
+                    // So goto the source directory (the file list is non empty)
+                    fd.setDirectory(System.getProperty("test.src", "."));
+                    fd.setVisible(true);
+                }
+            }).start();
+        r.delay(2000);
+        r.waitForIdle();
+
+        Component focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
+        if (focusedWindow != fd) {
+            throw new RuntimeException("Test failed - the file dialog isn't focused window, owner: " + focusedWindow);
+        }
+        r.waitForIdle();
+
+        r.keyPress(KeyEvent.VK_SPACE);
+        r.delay(50);
+        r.keyRelease(KeyEvent.VK_SPACE);
+        r.delay(1000);
+        fd.setVisible(false);
+        r.delay(1000);
+        r.waitForIdle();
+
+        if (!ISCthrownByFileListTest.passed){
+            throw new RuntimeException("Test failed.");
+        }
+
+    }// test()
+}// class ISCthrownByFileListTest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6378278/InputVerifierTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,413 @@
+/*
+ * 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 6378278
+  @summary Apparent missing key events causing Bugster to break
+  @author oleg.sukhodolsky: area=awt.focus
+  @run main InputVerifierTest
+*/
+
+/**
+ * InputVerifierTest.java
+ *
+ * summary: Apparent missing key events causing Bugster to break
+ */
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextArea;
+
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.InputVerifier;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+
+public class InputVerifierTest
+{
+
+    //*** test-writer defined static variables go here ***
+    static volatile boolean ivWasCalled = false;
+
+    private static void init()
+    {
+        //*** Create instructions for the user here ***
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test, simply wait until it is done.",
+            "The result (passed or failed) will be shown in the",
+            "message window below."
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        JFrame frame = new JFrame();
+        JTextField t1 = new JTextField();
+        t1.setInputVerifier(new InputVerifier() {
+            public boolean verify(JComponent input) {
+                Sysout.println("verify(" + input + ")");
+                ivWasCalled = true;
+                return true;
+            }
+        });
+        JTextField t2 = new JTextField();
+
+        frame.getContentPane().add(t1, BorderLayout.NORTH);
+        frame.getContentPane().add(t2, BorderLayout.SOUTH);
+        frame.setSize(200, 200);
+        frame.setVisible(true);
+
+        Robot r = null;
+        try {
+            r = new Robot();
+        } catch (AWTException e) {
+            e.printStackTrace();
+            InputVerifierTest.fail(e.toString());
+        }
+
+        try {
+            r.waitForIdle();
+
+            mouseClickOnComp(r, t1);
+            r.waitForIdle();
+
+            if (!t1.isFocusOwner()) {
+                throw new RuntimeException("t1 is not a focus owner");
+            }
+            ivWasCalled = false;
+            r.keyPress(KeyEvent.VK_TAB);
+            r.delay(10);
+            r.keyRelease(KeyEvent.VK_TAB);
+            r.waitForIdle();
+
+            if (!t2.isFocusOwner()) {
+                throw new RuntimeException("t2 is not a focus owner");
+            }
+            if (!ivWasCalled) {
+                throw new RuntimeException("InputVerifier was not called after tabbing");
+            }
+
+            mouseClickOnComp(r, t1);
+            r.waitForIdle();
+
+            if (!t1.isFocusOwner()) {
+                throw new RuntimeException("t1 is not a focus owner");
+            }
+
+            ivWasCalled = false;
+            mouseClickOnComp(r, t2);
+            r.waitForIdle();
+            if (!t2.isFocusOwner()) {
+                throw new RuntimeException("t2 is not a focus owner");
+            }
+            if (!ivWasCalled) {
+                throw new RuntimeException("InputVErifier was not called after mouse press");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            InputVerifierTest.fail(e.toString());
+        }
+
+        InputVerifierTest.pass();
+
+    }//End  init()
+
+    static void mouseClickOnComp(Robot r, Component comp) {
+        Point loc = comp.getLocationOnScreen();
+        loc.x += comp.getWidth() / 2;
+        loc.y += comp.getHeight() / 2;
+        r.mouseMove(loc.x, loc.y);
+        r.delay(10);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+        r.delay(10);
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    /*****************************************************
+     * Standard Test Machinery Section
+     * DO NOT modify anything in this section -- it's a
+     * standard chunk of code which has all of the
+     * synchronisation necessary for the test harness.
+     * By keeping it the same in all tests, it is easier
+     * to read and understand someone else's test, as
+     * well as insuring that all tests behave correctly
+     * with the test harness.
+     * There is a section following this for test-
+     * classes
+     ******************************************************/
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+
+    }//main
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        Sysout.println( "The test passed." );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }//pass()
+
+    public static synchronized void fail()
+    {
+        //test writer didn't specify why test failed, so give generic
+        fail( "it just plain failed! :-)" );
+    }
+
+    public static synchronized void fail( String whyFailed )
+    {
+        Sysout.println( "The test failed: " + whyFailed );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }//fail()
+
+}// class InputVerifierTest
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+        System.out.println(messageIn);
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6382144/EndlessLoopTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,409 @@
+/*
+ * 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 6382144
+  @summary REGRESSION: InputVerifier and JOptionPane
+  @author oleg.sukhodolsky: area=awt.focus
+  @run main EndlessLoopTest
+*/
+
+/**
+ * EndlessLoopTest.java
+ *
+ * summary: REGRESSION: InputVerifier and JOptionPane
+ */
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextArea;
+import java.awt.Toolkit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.InputVerifier;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+
+public class EndlessLoopTest
+{
+
+    //*** test-writer defined static variables go here ***
+    static volatile int n_iv_calls;
+
+
+    private static void init()
+    {
+        //*** Create instructions for the user here ***
+
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test, simply wait until it is done.",
+            "The result (passed or failed) will be shown in the",
+            "message window below."
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        JFrame frame = new JFrame();
+        final JDialog dialog = new JDialog(frame, true);
+        JButton button = new JButton("press me");
+        button.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent ae) {
+                    dialog.dispose();
+                }
+            });
+        dialog.getContentPane().add(button);
+        dialog.pack();
+
+        JTextField t1 = new JTextField();
+        t1.setInputVerifier(new InputVerifier() {
+            public boolean verify(JComponent input) {
+                n_iv_calls++;
+                if (n_iv_calls == 1) {
+                    dialog.setVisible(true);
+                }
+                return true;
+            }
+        });
+        JTextField t2 = new JTextField();
+
+
+        frame.getContentPane().add(t1, BorderLayout.NORTH);
+        frame.getContentPane().add(t2, BorderLayout.SOUTH);
+        frame.setSize(200, 200);
+        frame.setVisible(true);
+
+        Robot r = null;
+        try {
+            r = new Robot();
+        } catch (AWTException e) {
+            EndlessLoopTest.fail(e);
+        }
+
+        try {
+            r.waitForIdle();
+
+            mouseClickOnComp(r, t1);
+            r.waitForIdle();
+
+            if (!t1.isFocusOwner()) {
+                throw new RuntimeException("t1 is not a focus owner");
+            }
+            n_iv_calls = 0;
+            r.keyPress(KeyEvent.VK_TAB);
+            r.delay(10);
+            r.keyRelease(KeyEvent.VK_TAB);
+            r.waitForIdle();
+
+            mouseClickOnComp(r, button);
+            r.waitForIdle();
+        } catch (Exception e) {
+            EndlessLoopTest.fail(e);
+        }
+
+        if (n_iv_calls != 1) {
+            EndlessLoopTest.fail(new RuntimeException("InputVerifier was called " + n_iv_calls + " times"));
+        }
+
+        EndlessLoopTest.pass();
+
+    }//End  init()
+
+
+    static void mouseClickOnComp(Robot r, Component comp) {
+        Point loc = comp.getLocationOnScreen();
+        loc.x += comp.getWidth() / 2;
+        loc.y += comp.getHeight() / 2;
+        r.mouseMove(loc.x, loc.y);
+        r.delay(10);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+        r.delay(10);
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    /*****************************************************
+     * Standard Test Machinery Section
+     * DO NOT modify anything in this section -- it's a
+     * standard chunk of code which has all of the
+     * synchronisation necessary for the test harness.
+     * By keeping it the same in all tests, it is easier
+     * to read and understand someone else's test, as
+     * well as insuring that all tests behave correctly
+     * with the test harness.
+     * There is a section following this for test-
+     * classes
+     ******************************************************/
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+
+    }//main
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        Sysout.println( "The test passed." );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }//pass()
+
+    public static synchronized void fail( Exception whyFailed )
+    {
+        Sysout.println( "The test failed: " + whyFailed );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed.toString();
+        mainThread.interrupt();
+    }//fail()
+
+}// class EndlessLoopTest
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+        System.out.println(messageIn);
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6401036/InputVerifierTest2.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,384 @@
+/*
+ * 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 6401036
+  @summary  InputVerifier shouldn't be called when requestFocus() is called on comp from another toplevel
+  @author oleg.sukhodolsky: area=awt.focus
+  @run main InputVerifierTest2
+*/
+
+/**
+ * InputVerifierTest2.java
+ *
+ * summary: REGRESSION: InputVerifier and JOptionPane
+ */
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextArea;
+
+import java.awt.event.InputEvent;
+
+import javax.swing.InputVerifier;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+import javax.swing.JWindow;
+
+public class InputVerifierTest2
+{
+
+    private static void init()
+    {
+        //*** Create instructions for the user here ***
+
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test, simply wait until it is done.",
+            "The result (passed or failed) will be shown in the",
+            "message window below."
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        JTextField tf = new JTextField(10);
+        frame.getContentPane().add(tf);
+
+        final JWindow w = new JWindow(frame);
+        JButton btn1 = new JButton("window");
+        btn1.setName("bnt1");
+        w.getContentPane().add(btn1);
+        w.pack();
+        w.setVisible(true);
+
+        frame.setSize(200, 200);
+        frame.setVisible(true);
+
+
+        Robot r = null;
+        try {
+            r = new Robot();
+        } catch (AWTException e) {
+            InputVerifierTest2.fail(e);
+        }
+
+
+        try {
+            r.waitForIdle();
+            mouseClickOnComp(r, tf);
+            r.waitForIdle();
+
+            if (!tf.isFocusOwner()) {
+                throw new RuntimeException("t1 is not a focus owner");
+            }
+
+            tf.setInputVerifier(new InputVerifier() {
+                    public boolean verify(JComponent input) {
+                        System.err.println("verify on " + input);
+                        throw new RuntimeException("InputVerifier should not be called");
+                    }
+                });
+            btn1.requestFocus();
+        } catch (Exception e) {
+            InputVerifierTest2.fail(e);
+        }
+
+        InputVerifierTest2.pass();
+
+    }//End  init()
+
+
+    static void mouseClickOnComp(Robot r, Component comp) {
+        Point loc = comp.getLocationOnScreen();
+        loc.x += comp.getWidth() / 2;
+        loc.y += comp.getHeight() / 2;
+        r.mouseMove(loc.x, loc.y);
+        r.delay(10);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+        r.delay(10);
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    /*****************************************************
+     * Standard Test Machinery Section
+     * DO NOT modify anything in this section -- it's a
+     * standard chunk of code which has all of the
+     * synchronisation necessary for the test harness.
+     * By keeping it the same in all tests, it is easier
+     * to read and understand someone else's test, as
+     * well as insuring that all tests behave correctly
+     * with the test harness.
+     * There is a section following this for test-
+     * classes
+     ******************************************************/
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    // Not sure about what happens if multiple of this test are
+    //  instantiated in the same VM.  Being static (and using
+    //  static vars), it aint gonna work.  Not worrying about
+    //  it for now.
+    public static void main( String args[] ) throws InterruptedException
+    {
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            //The test passed, so just return from main and harness will
+            // interepret this return as a pass
+            return;
+        }
+        //At this point, neither test pass nor test fail has been
+        // called -- either would have thrown an exception and ended the
+        // test, so we know we have multiple threads.
+
+        //Test involves other threads, so sleep and wait for them to
+        // called pass() or fail()
+        try
+        {
+            Thread.sleep( sleepTime );
+            //Timed out, so fail the test
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            //The test harness may have interrupted the test.  If so, rethrow the exception
+            // so that the harness gets it and deals with it.
+            if( ! testGeneratedInterrupt ) throw e;
+
+            //reset flag in case hit this code more than once for some reason (just safety)
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+
+    }//main
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        Sysout.println( "The test passed." );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //first check if this is executing in main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //Still in the main thread, so set the flag just for kicks,
+            // and throw a test passed exception which will be caught
+            // and end the test.
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }//pass()
+
+    public static synchronized void fail( Exception whyFailed )
+    {
+        Sysout.println( "The test failed: " + whyFailed );
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+        //check if this called from main thread
+        if ( mainThread == Thread.currentThread() )
+        {
+            //If main thread, fail now 'cause not sleeping
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed.toString();
+        mainThread.interrupt();
+    }//fail()
+
+}// class InputVerifierTest2
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+        System.out.println(messageIn);
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ 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.
+-->
+
+<html>
+<!--  
+  @test
+  @bug        5090325
+  @summary    Tests that Window's child can be focused on XAWT.
+  @author     anton.tarasov@sun.com: area=awt.focus
+  @run        applet ChildWindowFocusTest.html
+  -->
+<head>
+<title>ChildWindowFocusTest</title>
+</head>
+<body>
+
+<h1>ChildWindowFocusTest<br>Bug ID: 5090325</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="ChildWindowFocusTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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        5090325
+  @summary    Tests that Window's child can be focused on XAWT.
+  @author     anton.tarasov@sun.com: area=awt.focus
+  @run        applet ChildWindowFocusTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.lang.reflect.*;
+
+public class ChildWindowFocusTest extends Applet {
+    Robot robot;
+    Frame frame = new Frame("Owner");
+    Button button0 = new Button("button-0");
+    TextField text0 = new TextField("text-0");
+    TextField text1 = new TextField("text-1");
+    Window win1 = new TestWindow(frame, text0, 110);
+    Window win2 = new TestWindow(win1, text1, 220);
+    Frame outerFrame = new Frame("Outer");
+    Button button1 = new Button("button-1");
+    int shift;
+
+    public void init() {
+        try {
+            robot = new Robot();
+        } catch (AWTException e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+        // Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+        Sysout.createDialogWithInstructions(new String[]
+            {"This is an AUTOMATIC test", "simply wait until it is done"});
+
+        Rectangle bounds = Sysout.dialog.getBounds();
+        shift = (int)(bounds.x + bounds.width + 10);
+    }
+
+    public void start() {
+
+        frame.setBounds(0, 50, 400, 100);
+        frame.setLayout(new FlowLayout());
+        frame.add(button0);
+
+        outerFrame.setBounds(0, 390, 400, 100);
+        outerFrame.setLayout(new FlowLayout());
+        outerFrame.add(button1);
+
+        adjustAndShow(new Component[] {frame, win1, win2, outerFrame});
+        robot.waitForIdle();
+
+        test();
+    }
+
+    void adjustAndShow(Component[] comps) {
+        for (Component comp: comps) {
+            comp.setLocation(shift, (int)comp.getLocation().getY());
+            comp.setVisible(true);
+            robot.waitForIdle();
+        }
+    }
+
+    void test() {
+        clickOnCheckFocusOwner(button0);
+        clickOnCheckFocusOwner(text1);
+        clickOnCheckFocusOwner(button1);
+        clickOn(frame);
+        checkFocusOwner(text1);
+        clickOnCheckFocusOwner(text0);
+        clickOnCheckFocusOwner(button1);
+        clickOn(frame);
+        checkFocusOwner(text0);
+
+        Sysout.println("Test passed.");
+    }
+
+    void clickOnCheckFocusOwner(Component c) {
+        clickOn(c);
+        if (!checkFocusOwner(c)) {
+            throw new RuntimeException("Test failed: couldn't focus <" + c + "> by mouse click!");
+        }
+    }
+
+    boolean checkFocusOwner(Component comp) {
+        return (comp == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+    }
+
+    void clickOn(Component c) {
+        Point p = c.getLocationOnScreen();
+        Dimension d = c.getSize();
+
+        Sysout.println("Clicking " + c);
+
+        if (c instanceof Frame) {
+            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
+        } else {
+            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+        }
+        robot.delay(50);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(50);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.waitForIdle();
+    }
+
+}
+
+class TestWindow extends Window {
+    TestWindow(Window owner, Component comp, int x) {
+        super(owner);
+        setBackground(Color.blue);
+        setLayout(new FlowLayout());
+        add(comp);
+        comp.setBackground(Color.yellow);
+        setBounds(0, x, 100, 100);
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+  @test
+  @bug        6386592
+  @summary    Tests that disposing a dialog doesn't activate its invisible owner.
+  @author     anton.tarasov@sun.com: area=awt.focus
+  @run        applet DisposeDialogNotActivateOwnerTest.html
+  -->
+<head>
+<title>DisposeDialogNotActivateOwnerTest</title>
+</head>
+<body>
+ 
+<h1>DisposeDialogNotActivateOwnerTest<br>Bug ID: 6386592</h1>
+ 
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+ 
+<APPLET CODE=DisposeDialogNotActivateOwnerTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,258 @@
+/*
+ * 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       6386592
+  @summary   Tests that disposing a dialog doesn't activate its invisible owner.
+  @author    anton.tarasov@sun.com: area=awt.focus
+  @run       applet DisposeDialogNotActivateOwnerTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+public class DisposeDialogNotActivateOwnerTest extends Applet {
+    Robot robot;
+
+    Frame frame = new Frame("Owner Frame");
+    Dialog dialog = new Dialog(new Frame(), "Owned Dialog");
+    Button frameButton = new Button("button");
+
+    static boolean passed = false;
+
+    public static void main(String[] args) {
+        DisposeDialogNotActivateOwnerTest app = new DisposeDialogNotActivateOwnerTest();
+        app.init();
+        app.start();
+    }
+
+    public void init() {
+        try {
+            robot = new Robot();
+        } catch (AWTException e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+        // Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+        Sysout.createDialogWithInstructions(new String[]
+            {"This is automatic test. Simply wait until it is done."
+            });
+
+        frame.setBounds(800, 50, 200, 100);
+        frame.add(frameButton);
+        dialog.setBounds(800, 300, 200, 100);
+    }
+
+    public void start() {
+
+        frameButton.addFocusListener(new FocusAdapter() {
+                public void focusGained(FocusEvent e) {
+                    passed = true;
+                }
+            });
+
+        frame.setVisible(true);
+        robot.waitForIdle();
+
+        // make sure the frame is focused
+        clickOn(frame);
+        if (!frame.isFocused()) {
+            throw new RuntimeException("Error: a frame didn't get initial focus.");
+        }
+
+        dialog.setVisible(true);
+        robot.waitForIdle();
+
+        // make sure the dialog is focused
+        if (!dialog.isFocused()) {
+            throw new RuntimeException("Error: a dialog didn't get initial focus.");
+        }
+
+        dialog.dispose();
+        robot.waitForIdle();
+
+        if (passed) {
+            Sysout.println("Test passed.");
+        } else {
+            throw new RuntimeException("Test failed: a dialog activates invisible owner when disposed!");
+        }
+    }
+
+    void clickOn(Component c) {
+        Point p = c.getLocationOnScreen();
+        Dimension d = c.getSize();
+
+        if (c instanceof Frame) {
+            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
+        } else {
+            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+        }
+
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(20);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        robot.waitForIdle();
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- a/jdk/test/java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -27,7 +27,7 @@
   @summary   Tests that EmbeddedFrame can be focused.
   @author    anton.tarasov: area=awt-focus
   @library   ../../regtesthelpers
-  @build     Util
+  @build     Util UtilInternal
   @run       main FocusEmbeddedFrameTest
 */
 
@@ -37,6 +37,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.lang.reflect.InvocationTargetException;
 import test.java.awt.regtesthelpers.Util;
+import test.java.awt.regtesthelpers.UtilInternal;
 
 public class FocusEmbeddedFrameTest extends Applet {
     static Frame embedder = new Frame("Embedder");
@@ -71,7 +72,7 @@
         embedder.addNotify();
 
         try {
-            ef = Util.createEmbeddedFrame(embedder);
+            ef = UtilInternal.createEmbeddedFrame(embedder);
         } catch (Throwable t) {
             t.printStackTrace();
             throw new Error("Test error: couldn't create an EmbeddedFrame!");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ 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.
+-->
+
+<html>
+<!--  
+  @test
+  @bug        5082319
+  @summary    Tests that focus request for already focused component doesn't block key events.
+  @author     anton.tarasov@sun.com
+  @run applet FocusSubRequestTest.html
+  -->
+<head>
+<title>FocusSubRequestTest</title>
+</head>
+<body>
+
+<h1>FocusSubRequestTest<br>Bug ID: 5082319</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="FocusSubRequestTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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        5082319
+  @summary    Tests that focus request for already focused component doesn't block key events.
+  @author     anton.tarasov@sun.com
+  @run applet FocusSubRequestTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+public class FocusSubRequestTest extends Applet {
+    Frame frame = new Frame("Test Frame");
+    Button button = new Button("button");
+    boolean passed = false;
+    Robot robot;
+
+    public void init() {
+        frame.add(button);
+        button.addFocusListener(new FocusAdapter() {
+                public void focusGained(FocusEvent e) {
+                    System.out.println("FocusSubRequestTest: focusGained for: " + e.getSource());
+                    ((Component)e.getSource()).requestFocus();
+                }
+            });
+
+        button.addKeyListener(new KeyAdapter() {
+                public void keyPressed(KeyEvent e) {
+                    System.out.println("FocusSubRequestTest: keyPressed for: " + e.getSource());
+                    passed = true;
+                }
+            });
+
+        try {
+            robot = new Robot();
+        } catch(Exception e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+    }
+
+    public void start() {
+        frame.pack();
+        frame.setLocation(getLocation().x + getSize().width + 20, 0);
+        frame.setVisible(true);
+
+        waitTillShown(button);
+        frame.toFront();
+
+        robot.delay(100);
+        robot.keyPress(KeyEvent.VK_K);
+        robot.delay(100);
+        robot.keyRelease(KeyEvent.VK_K);
+
+        robot.waitForIdle();
+
+        if(passed) {
+            System.out.println("Test passed.");
+        } else {
+            throw new RuntimeException("Test failed.");
+        }
+    }
+
+    private void waitTillShown(Component component) {
+        while (true) {
+            try {
+                Thread.sleep(100);
+                component.getLocationOnScreen();
+                break;
+            } catch(InterruptedException ie) {
+                throw new RuntimeException(ie);
+            } catch(IllegalComponentStateException icse) {}
+        }
+    }
+}
--- a/jdk/test/java/awt/Focus/KeyEventForBadFocusOwnerTest/KeyEventForBadFocusOwnerTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Focus/KeyEventForBadFocusOwnerTest/KeyEventForBadFocusOwnerTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -38,13 +38,11 @@
 
 
 import java.awt.Robot;
-import java.awt.Toolkit;
 
 import java.awt.event.*;
 
 import javax.swing.*;
 import javax.swing.event.*;
-import sun.awt.SunToolkit;
 
 public class KeyEventForBadFocusOwnerTest {
     final static String ITEM_ONE_TEXT = "one";
@@ -55,7 +53,6 @@
     volatile static boolean unexpectedItemSelected = false;
 
     static Robot robot;
-    static SunToolkit toolkit;
 
     public static void main(String[] args) throws Exception {
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -122,16 +119,15 @@
             }
         });
 
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
 
         robot = new Robot();
         robot.setAutoDelay(100);
+        robot.waitForIdle();
 
         Util.hitMnemonics(robot, KeyEvent.VK_O);
         Util.hitMnemonics(robot, KeyEvent.VK_T);
 
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000); // workaround for MacOS
 
         if (unexpectedItemSelected) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+  @test
+  @bug        6382750
+  @summary
+  @author     anton.tarasov@sun.com: area=awt.focus
+  @run        applet ModalDialogInitialFocusTest.html
+  -->
+<head>
+<title>ModalDialogInitialFocusTest</title>
+</head>
+<body>
+ 
+<h1>ModalDialogInitialFocusTest<br>Bug ID: 6382750</h1>
+ 
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+ 
+<APPLET CODE=ModalDialogInitialFocusTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,253 @@
+/*
+ * 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       6382750
+  @summary   Tests that modal dialog doesn't request extra initial focus on show.
+  @author    anton.tarasov@sun.com: area=awt.focus
+  @run       applet ModalDialogInitialFocusTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.lang.reflect.InvocationTargetException;
+
+public class ModalDialogInitialFocusTest extends Applet {
+    Robot robot;
+
+    Dialog dialog = new Dialog((Window)null, "Test Dialog", Dialog.ModalityType.TOOLKIT_MODAL);
+    Button button = new Button("button");
+
+    volatile static boolean passed = true;
+
+    public static void main(String[] args) {
+        ModalDialogInitialFocusTest app = new ModalDialogInitialFocusTest();
+        app.init();
+        app.start();
+    }
+
+    public void init() {
+        try {
+            robot = new Robot();
+        } catch (AWTException e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+        // Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+        Sysout.createDialogWithInstructions(new String[]
+            {"This is automatic test. Simply wait until it is done."
+            });
+    }
+
+    public void start() {
+
+        dialog.setLayout(new FlowLayout());
+        dialog.add(button);
+        dialog.setBounds(800, 0, 100, 100);
+
+        dialog.addFocusListener(new FocusAdapter() {
+                // The only expected FOCUS_GAINED is on the button.
+                public void focusGained(FocusEvent e) {
+                    passed = false;
+                }
+            });
+
+        test();
+    }
+
+    void test() {
+        new Thread(new Runnable() {
+                public void run() {
+                  dialog.setVisible(true);
+                }
+            }).start();
+
+        waitTillShown(dialog);
+
+        robot.waitForIdle();
+
+        dialog.dispose();
+
+        if (passed) {
+            Sysout.println("Test passed.");
+        } else {
+            throw new RuntimeException("Test failed: dialog requests extra focus on show!");
+        }
+    }
+
+    void waitTillShown(Component c) {
+        while (true) {
+            try {
+                Thread.sleep(100);
+                c.getLocationOnScreen();
+                break;
+            } catch (InterruptedException ie) {
+                ie.printStackTrace();
+                break;
+            } catch (IllegalComponentStateException e) {
+            }
+        }
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+  @test
+  @bug        5028014
+  @summary    Focus request & mouse click being performed nearly synchronously shouldn't break the focus subsystem
+  @author     anton.tarasov@sun.com: area=awt-focus
+  @run        applet MouseClickRequestFocusRaceTest.html
+  -->
+<head>
+<title>MouseClickRequestFocusRaceTest</title>
+</head>
+<body>
+ 
+<h1>MouseClickRequestFocusRaceTest<br>Bug ID: 5028014</h1>
+ 
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+ 
+<APPLET CODE=MouseClickRequestFocusRaceTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,307 @@
+/*
+ * 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       5028014
+  @summary   Focus request & mouse click performed nearly synchronously shouldn't lead to a focus race.
+  @author    anton.tarasov@sun.com: area=awt-focus
+  @run       applet MouseClickRequestFocusRaceTest.html
+*/
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+public class MouseClickRequestFocusRaceTest extends Applet {
+    Robot robot;
+    JFrame frame1 = new JFrame("Frame-1") {
+            public String toString() { return "Frame-1";}
+        };
+    JFrame frame2 = new JFrame("Frame-2") {
+            public String toString() { return "Frame-2";}
+        };
+    JButton button1 = new JButton("button-1") {
+            public String toString() { return "button-1";}
+        };
+    JButton button2 = new JButton("button-2") {
+            public String toString() { return "button-2";}
+        };
+    JPopupMenu popup = new JPopupMenu();
+
+    public static void main(String[] args) {
+        MouseClickRequestFocusRaceTest app = new MouseClickRequestFocusRaceTest();
+        app.init();
+        app.start();
+    }
+
+    public void init() {
+        try {
+            robot = new Robot();
+        } catch (AWTException e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+        // Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+        Sysout.createDialogWithInstructions(new String[]
+            {"Automatic test. Simply wait until it is done."
+            });
+    }
+
+    public void start() {
+        frame1.add(button1);
+        frame2.add(button2);
+        frame1.setBounds(0, 0, 200, 300);
+        frame2.setBounds(300, 0, 200, 300);
+        frame1.setLayout(new FlowLayout());
+        frame2.setLayout(new FlowLayout());
+
+        popup.add(new JMenuItem("black"));
+        popup.add(new JMenuItem("yellow"));
+        popup.add(new JMenuItem("white"));
+
+        frame1.add(popup);
+
+        frame1.addMouseListener(new MouseAdapter() {
+                void popup(MouseEvent e) {
+                    if (e.isPopupTrigger()) {
+                        Point loc = button1.getLocation();
+                        popup.show(button1, e.getX() - loc.x, e.getY() - loc.y);
+                    }
+                }
+                public void mousePressed(MouseEvent e) {
+                    popup(e);
+                }
+                public void mouseReleased(MouseEvent e) {
+                    popup(e);
+                }
+            });
+
+        frame2.addMouseListener(new MouseAdapter() {
+                public void mousePressed(MouseEvent e) {
+                    button1.requestFocusInWindow();
+                }
+            });
+
+        frame2.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+        frame1.setVisible(true);
+        frame2.setVisible(true);
+//        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.delay(1000);
+
+        test();
+    }
+
+    public void test() {
+        // Right click Frame-1
+        robot.mouseMove(frame1.getLocation().x + 100, frame1.getLocation().y + 200);
+        robot.mousePress(InputEvent.BUTTON3_MASK);
+        robot.delay(100);
+        robot.mouseRelease(InputEvent.BUTTON3_MASK);
+
+//        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.delay(1000);
+
+        // Left click Frame-2
+        robot.mouseMove(frame2.getLocation().x + 100, frame1.getLocation().y + 200);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(100);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+//        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.delay(1000);
+
+        JComponent focusOwner = (JComponent)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+        JFrame focusedWindow = (JFrame)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
+
+        Sysout.println("focus owner: " + focusOwner);
+        Sysout.println("focused window: " + focusedWindow);
+
+        // Verify that the focused window is the ancestor of the focus owner
+        if (!focusedWindow.isAncestorOf(focusOwner)) {
+            throw new TestFailedException("The focus owner is not in the focused window!");
+        }
+
+        // Try to close native focused window
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_F4);
+        robot.keyRelease(KeyEvent.VK_F4);
+        robot.keyRelease(KeyEvent.VK_ALT);
+
+//        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.delay(1000);
+
+        // Verify that the Java focused window really mapped the native focused window.
+        if (focusedWindow.isVisible()) {
+            throw new TestFailedException("The focused window is different on Java and on the native level.");
+        }
+    }
+
+    class TestFailedException extends RuntimeException {
+        public TestFailedException(String cause) {
+            super("Test failed.");
+            Sysout.println(cause);
+        }
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+//        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+//        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+//        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- a/jdk/test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -34,7 +34,6 @@
 import java.awt.event.*;
 import java.util.concurrent.Callable;
 import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
 import test.java.awt.regtesthelpers.Util;
 
 public class SimpleWindowActivationTest {
@@ -45,7 +44,6 @@
     private static Button wbutton;
     private static Label label;
     private static Robot robot;
-    private static SunToolkit toolkit;
 
     public static void main(String[] args) throws Exception {
 
@@ -54,7 +52,6 @@
             return;
         }
 
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -66,10 +63,10 @@
         }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
 
         createAndShowWindow();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         createAndShowFrame();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // click on Frame
         clickOn(getClickPoint(frame));
@@ -96,7 +93,7 @@
         //         won't activate it.
 
         window.setFocusableWindowState(false);
-        toolkit.realSync();
+        robot.waitForIdle();
 
 
         clickOn(getClickPoint(label));
@@ -136,11 +133,12 @@
     static void clickOn(Point point) {
 
         robot.mouseMove(point.x, point.y);
+        robot.waitForIdle();
 
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 
     static Point getClickPoint(Component c) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/GetBoundsResizeTest/GetBoundsResizeTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 1998, 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 4103095
+   @summary Test for getBounds() after a Frame resize.
+   @author andrei.dmitriev : area=awt.toplevel
+   @run main/manual GetBoundsResizeTest
+*/
+
+import java.applet.Applet;
+import java.lang.*;
+import java.awt.*;
+import java.awt.event.*;
+
+class Globals {
+  static boolean testPassed=false;
+  static Thread mainThread=null;
+}
+
+public class GetBoundsResizeTest extends Applet {
+
+  public static void main(String args[]) throws Exception {
+    GetBoundsResizeTest app = new GetBoundsResizeTest();
+    app.start();
+    Globals.mainThread = Thread.currentThread();
+    try {
+      Thread.sleep(300000);
+    } catch (InterruptedException e) {
+      if (!Globals.testPassed)
+        throw new Exception("GetBoundsResizeTest failed.");
+    }
+  }
+
+  public void start()
+  {
+    String[] message = {
+      "Resize the window using the upper left corner.",
+      "Press the button to print the result of getBounds() to the terminal.",
+      "If getBounds() prints the correct values for the window",
+      "then click Pass, else click Fail."
+    };
+    new TestDialog(new Frame(), "GetBoundsResizeTest", message).start();
+    new GetBoundsResizeTester("GetBoundsResizeTester").start();
+  }
+}
+
+////////////////////////////////////////////////////////////////////////
+//  Test Dialog
+////////////////////////////////////////////////////////////////////////
+
+class TestDialog extends Dialog
+    implements ActionListener {
+
+  static TextArea output;
+  Button passButton;
+  Button failButton;
+  String name;
+
+  public TestDialog(Frame frame, String name, String[] message)
+  {
+    super(frame, name + " Pass/Fail Dialog");
+    this.name = name;
+    int maxStringLength = 0;
+    for (int i=0; i<message.length; i++) {
+      maxStringLength = Math.max(maxStringLength, message[i].length());
+    }
+    output = new TextArea(10, maxStringLength);
+    add("North", output);
+    for (int i=0; i<message.length; i++){
+        output.append(message[i] + "\n");
+    }
+    Panel buttonPanel = new Panel();
+    passButton = new Button("Pass");
+    failButton = new Button("Fail");
+    passButton.addActionListener(this);
+    failButton.addActionListener(this);
+    buttonPanel.add(passButton);
+    buttonPanel.add(failButton);
+    add("South", buttonPanel);
+    pack();
+  }
+
+  public void start()
+  {
+    show();
+  }
+
+  public void actionPerformed(ActionEvent event)
+  {
+    if ( event.getSource() == passButton ) {
+      Globals.testPassed = true;
+      System.err.println(name + " Passed.");
+    }
+    else if ( event.getSource() == failButton ) {
+      Globals.testPassed = false;
+      System.err.println(name + " Failed.");
+    }
+    this.dispose();
+    if (Globals.mainThread != null)
+      Globals.mainThread.interrupt();
+  }
+}
+
+
+  ////////////////////////////////////////////////////////////////////////
+  //  Test Class
+  ////////////////////////////////////////////////////////////////////////
+
+class GetBoundsResizeTester extends Frame {
+    Button b = new Button("Press");
+
+  GetBoundsResizeTester(String name)
+  {
+    super(name);
+    final Frame f = this;
+    Panel p = new Panel();
+    f.add(p);
+    p.setLayout(new BorderLayout());
+    b.addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent be){
+        Point cp = b.getLocationOnScreen();
+        TestDialog.output.append("Current Frame.getBounds() = " + f.getBounds()+"\n");
+      }
+    });
+    p.add("Center", b);
+    f.pack();
+  }
+
+  public void start ()
+  {
+      setVisible(true);
+      Robot robot;
+      try {
+          robot = new Robot();
+          robot.waitForIdle();
+      }catch(Exception ignorex) {
+      }
+      Point cp = b.getLocationOnScreen();
+      TestDialog.output.append("Original Frame.getBounds() = " + this.getBounds()+"\n");
+  }
+
+  public static void main(String[] args)
+  {
+    new GetBoundsResizeTester("GetBoundsResizeTester").start();
+  }
+
+}
--- a/jdk/test/java/awt/FullScreen/8013581/bug8013581.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/FullScreen/8013581/bug8013581.java	Fri Dec 05 14:55:08 2014 +0300
@@ -29,7 +29,6 @@
  * @run main bug8013581
  */
 
-import sun.awt.*;
 import java.awt.*;
 import java.awt.event.*;
 
@@ -42,12 +41,11 @@
                 .getLocalGraphicsEnvironment();
         final GraphicsDevice[] devices = ge.getScreenDevices();
 
-        final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
         final Robot robot = new Robot();
         robot.setAutoDelay(50);
 
         createAndShowGUI();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Exception error = null;
         for (final GraphicsDevice device : devices) {
@@ -56,14 +54,14 @@
             }
 
             device.setFullScreenWindow(frame);
-            sleep();
+            sleep(robot);
 
             robot.keyPress(KeyEvent.VK_A);
             robot.keyRelease(KeyEvent.VK_A);
-            toolkit.realSync();
+            robot.waitForIdle();
 
             device.setFullScreenWindow(null);
-            sleep();
+            sleep(robot);
 
             if (listenerCallCounter != 2) {
                 error = new Exception("Test failed: KeyListener called " + listenerCallCounter + " times instead of 2!");
@@ -98,8 +96,8 @@
         frame.setVisible(true);
     }
 
-    private static void sleep() {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+    private static void sleep(Robot robot) {
+        robot.waitForIdle();
         try {
             Thread.sleep(2000);
         } catch (InterruptedException ignored) {
--- a/jdk/test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java	Fri Dec 05 14:55:08 2014 +0300
@@ -30,12 +30,9 @@
 import java.awt.GraphicsEnvironment;
 import java.awt.Insets;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.Window;
 import java.awt.image.BufferedImage;
 
-import sun.awt.SunToolkit;
-
 /**
  * @test
  * @bug 8003173 7019055
@@ -45,6 +42,7 @@
 public final class FullScreenInsets {
 
     private static boolean passed = true;
+    private static Robot robot = null;
 
     public static void main(final String[] args) {
         final GraphicsEnvironment ge = GraphicsEnvironment
@@ -147,7 +145,15 @@
     }
 
     private static void sleep() {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        if(robot == null) {
+            try {
+                robot = new Robot();
+            }catch(AWTException ae) {
+                ae.printStackTrace();
+                throw new RuntimeException("Cannot create Robot.");
+            }
+        }
+        robot.waitForIdle();
         try {
             Thread.sleep(2000);
         } catch (InterruptedException ignored) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+  @test
+  @bug        6391688
+  @summary    Tests that next mnemonic KeyTyped is consumed for a modal dialog.
+  @author     anton.tarasov@sun.com: area=awt.focus
+  @run        applet ConsumeForModalDialogTest.html
+  -->
+<head>
+<title>ConsumeForModalDialogTest</title>
+</head>
+<body>
+ 
+<h1>ConsumeForModalDialogTest<br>Bug ID: 6391688</h1>
+ 
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+ 
+<APPLET CODE=ConsumeForModalDialogTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,281 @@
+/*
+ * 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       6391688
+  @summary   Tests that next mnemonic KeyTyped is consumed for a modal dialog.
+  @author    anton.tarasov@sun.com: area=awt.focus
+  @run       applet ConsumeForModalDialogTest.html
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.lang.reflect.InvocationTargetException;
+
+public class ConsumeForModalDialogTest extends Applet {
+    Robot robot;
+    JFrame frame = new JFrame("Test Frame");
+    JDialog dialog = new JDialog((Window)null, "Test Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
+    JTextField text = new JTextField();
+    static boolean passed = true;
+
+    public static void main(String[] args) {
+        ConsumeForModalDialogTest app = new ConsumeForModalDialogTest();
+        app.init();
+        app.start();
+    }
+
+    public void init() {
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(50);
+        } catch (AWTException e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+        // Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+        Sysout.createDialogWithInstructions(new String[]
+            {"This is automatic test. Simply wait until it is done."
+            });
+    }
+
+    public void start() {
+
+        text.addKeyListener(new KeyAdapter() {
+                public void keyTyped(KeyEvent e) {
+                    Sysout.println(e.toString());
+                    passed = false;
+                }
+            });
+
+        JMenuItem testItem = new JMenuItem();
+        testItem.setMnemonic('s');
+        testItem.setText("Test");
+
+        testItem.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent ae) {
+                    dialog.setVisible(true);
+            }
+        });
+
+        JMenu menu = new JMenu();
+        menu.setMnemonic('f');
+        menu.setText("File");
+        menu.add(testItem);
+
+        JMenuBar menuBar = new JMenuBar();
+        menuBar.add(menu);
+
+        dialog.setSize(100, 100);
+        dialog.add(text);
+
+        frame.setJMenuBar(menuBar);
+        frame.setSize(100, 100);
+        frame.setVisible(true);
+
+        robot.waitForIdle();
+
+        if (!frame.isFocusOwner()) {
+            Point loc = frame.getLocationOnScreen();
+            Dimension size = frame.getSize();
+            robot.mouseMove(loc.x + size.width/2, loc.y + size.height/2);
+            robot.delay(10);
+            robot.mousePress(MouseEvent.BUTTON1_MASK);
+            robot.delay(10);
+            robot.mouseRelease(MouseEvent.BUTTON1_MASK);
+
+            robot.waitForIdle();
+
+            int iter = 10;
+            while (!frame.isFocusOwner() && iter-- > 0) {
+                robot.delay(200);
+            }
+            if (iter <= 0) {
+                Sysout.println("Test: the frame couldn't be focused!");
+                return;
+            }
+        }
+
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_F);
+        robot.delay(10);
+        robot.keyRelease(KeyEvent.VK_F);
+        robot.keyRelease(KeyEvent.VK_ALT);
+
+        robot.waitForIdle();
+
+        robot.keyPress(KeyEvent.VK_S);
+        robot.delay(10);
+        robot.keyRelease(KeyEvent.VK_S);
+
+        robot.delay(1000);
+
+        if (passed) {
+            Sysout.println("Test passed.");
+        } else {
+            throw new RuntimeException("Test failed! Enexpected KeyTyped came into the JTextField.");
+        }
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,45 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+  @test
+  @bug        6346690
+  @summary    Tests that key_typed is consumed after mnemonic key_pressed is handled for a menu item.
+  @author     anton.tarasov@sun.com: area=awt-focus
+  @library   ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run        applet ConsumeNextMnemonicKeyTypedTest.html
+  -->
+<head>
+<title>ConsumeNextMnemonicKeyTypedTest</title>
+</head>
+<body>
+ 
+<h1>ConsumeNextMnemonicKeyTypedTest<br>Bug ID: 6346690</h1>
+ 
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+ 
+<APPLET CODE=ConsumeNextMnemonicKeyTypedTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,300 @@
+/*
+ * 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       6346690
+  @summary   Tests that key_typed is consumed after mnemonic key_pressed is handled for a menu item.
+  @author    anton.tarasov@sun.com: area=awt-focus
+  @library   ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run       applet ConsumeNextMnemonicKeyTypedTest.html
+*/
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+
+public class ConsumeNextMnemonicKeyTypedTest extends Applet {
+    Robot robot;
+    JFrame frame = new JFrame("Test Frame");
+    JTextField text = new JTextField();
+    JMenuBar bar = new JMenuBar();
+    JMenu menu = new JMenu("Menu");
+    JMenuItem item = new JMenuItem("item");
+
+    public static void main(String[] args) {
+        ConsumeNextMnemonicKeyTypedTest app = new ConsumeNextMnemonicKeyTypedTest();
+        app.init();
+        app.start();
+    }
+
+    public void init() {
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(50);
+        } catch (AWTException e) {
+            throw new RuntimeException("Error: unable to create robot", e);
+        }
+        // Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+        Sysout.createDialogWithInstructions(new String[]
+            {"Automatic test. Simply wait until it's done."});
+    }
+
+    public void start() {
+        menu.setMnemonic('f');
+        item.setMnemonic('i');
+        menu.add(item);
+        bar.add(menu);
+
+        frame.add(text);
+        frame.setJMenuBar(bar);
+        frame.pack();
+
+        frame.setLocation(800, 0);
+        frame.setVisible(true);
+
+        test();
+    }
+
+    void test() {
+
+        robot.waitForIdle();
+
+        if (!text.isFocusOwner()) {
+            robot.mouseMove(text.getLocationOnScreen().x + 5, text.getLocationOnScreen().y + 5);
+            robot.delay(100);
+            robot.mousePress(MouseEvent.BUTTON1_MASK);
+            robot.delay(100);
+            robot.mouseRelease(MouseEvent.BUTTON1_MASK);
+
+            int iter = 10;
+            while (!text.isFocusOwner() && iter-- > 0) {
+                robot.delay(200);
+            }
+            if (iter <= 0) {
+                Sysout.println("Test: text field couldn't be focused!");
+                return;
+            }
+        }
+
+        robot.keyPress(KeyEvent.VK_A);
+        robot.delay(100);
+        robot.keyRelease(KeyEvent.VK_A);
+
+        robot.waitForIdle();
+
+        String charA = text.getText();
+        System.err.println("Test: character typed with VK_A: " + charA);
+
+        robot.keyPress(KeyEvent.VK_BACK_SPACE);
+        robot.delay(100);
+        robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+
+        robot.waitForIdle();
+
+        if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+            robot.keyPress(KeyEvent.VK_CONTROL);
+        }
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_F);
+        robot.delay(100);
+        robot.keyRelease(KeyEvent.VK_F);
+        robot.keyRelease(KeyEvent.VK_ALT);
+        if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+            robot.keyRelease(KeyEvent.VK_CONTROL);
+        }
+
+        robot.waitForIdle();
+
+        String string = text.getText();
+
+        robot.keyPress(KeyEvent.VK_I);
+        robot.delay(100);
+        robot.keyRelease(KeyEvent.VK_I);
+
+        robot.waitForIdle();
+
+        Sysout.println("Test: character typed after mnemonic key press: " + text.getText());
+
+        if (!text.getText().equals(string)) {
+            throw new RuntimeException("Test failed!");
+        }
+
+        robot.keyPress(KeyEvent.VK_A);
+        robot.delay(100);
+        robot.keyRelease(KeyEvent.VK_A);
+
+        robot.waitForIdle();
+
+        System.err.println("Test: chracter typed with VK_A: " + text.getText());
+
+        if (!charA.equals(text.getText())) {
+            throw new RuntimeException("Test failed!");
+        }
+
+        Sysout.println("Test passed.");
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,374 @@
+/*
+ * 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 4799136
+@summary Tests that type-ahead for dialog works and doesn't block program
+@author Dmitry.Cherepanov@SUN.COM area=awt.focus
+@run main EnqueueWithDialogButtonTest
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * Tests that type-ahead works correctly. That means
+ * that the key events are not delivered until a focus
+ * transfer is completed.
+ * There is another pretty similar test EnqueueWithDialogTest
+ * written in time before 6347235 resolution. We'll keep it
+ * to track quite unrelated suspicious waitForIdle behavior.
+ */
+
+public class EnqueueWithDialogButtonTest
+{
+    static Frame f;
+    static Button b;
+    static Dialog d;
+    static Button ok;
+    static CountDownLatch pressLatch = new CountDownLatch(1);
+    static CountDownLatch robotLatch = new CountDownLatch(1);
+    static volatile boolean gotFocus = false;
+    static Robot robot;
+    public static void main(String args[]) throws Exception {
+        EnqueueWithDialogButtonTest test = new EnqueueWithDialogButtonTest();
+        test.init();
+        test.start();
+    }
+    public void init()
+    {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+                public void eventDispatched(AWTEvent e) {
+                    if (e instanceof InputEvent){
+                        System.err.println(e.toString()+","+((InputEvent)e).getWhen());
+                    }else{
+                        System.err.println(e.toString());
+                    }
+                 }
+            }, AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
+
+
+        f = new Frame("frame");
+        f.setPreferredSize(new Dimension(100,100));
+        f.setLocation(100,50);
+        b = new Button("press");
+        d = new Dialog(f, "dialog", true);
+        d.setPreferredSize(new Dimension(70,70));
+        ok = new Button("ok");
+        d.add(ok);
+        d.pack();
+        ok.addKeyListener(new KeyAdapter() {
+                public void keyPressed(KeyEvent e) {
+                    System.err.println("OK pressed: should arrive after got focus");
+                    d.dispose();
+                    f.dispose();
+                    // Typed-ahead key events should only be accepted if
+                    // they arrive after FOCUS_GAINED
+                    if (gotFocus) {
+                        pressLatch.countDown();
+                    }
+                }
+            });
+        ok.addFocusListener(new FocusAdapter() {
+                public void focusGained(FocusEvent e) {
+                    gotFocus = true;
+                    System.err.println("OK got focus");
+                }
+            });
+        f.add(b);
+        f.pack();
+        b.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    System.err.println(e.toString()+","+e.getWhen());
+                    System.err.println("B pressed");
+                    robotLatch.countDown();
+
+                    EventQueue.invokeLater(new Runnable() {
+                            public void run() {
+                                waitTillShown(d);
+                                EnqueueWithDialogButtonTest.this.d.toFront();
+                                EnqueueWithDialogButtonTest.this.moveMouseOver(d);
+                            }
+                        });
+
+                    // This will cause enqueue the following key events
+                    d.setVisible(true);
+                }
+            });
+
+    }//End  init()
+
+    public void start () throws Exception
+    {
+
+        robot = new Robot();
+        robot.setAutoDelay(50);
+
+        f.setVisible(true);
+        waitTillShown(b);
+        System.err.println("b is shown");
+        f.toFront();
+        moveMouseOver(f);
+        robot.waitForIdle();
+        robot.delay(100);
+        makeFocused(b);
+        robot.waitForIdle();
+        robot.delay(100);
+        System.err.println("b is focused");
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        boolean ok = robotLatch.await(1, TimeUnit.SECONDS);
+        if(!ok) {
+            throw new RuntimeException("Was B button pressed?");
+        }
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.delay(500);
+        ok = pressLatch.await(3, TimeUnit.SECONDS);
+        if(!ok) {
+            throw new RuntimeException("Type-ahead doesn't work");
+        }
+
+    }// start()
+
+    private void moveMouseOver(Container c) {
+        Point p = c.getLocationOnScreen();
+        Dimension d = c.getSize();
+        robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+    }
+
+    private void waitTillShown(Component c) {
+        while (true) {
+            try {
+                Thread.sleep(100);
+                c.getLocationOnScreen();
+                break;
+            } catch (InterruptedException ie) {
+                ie.printStackTrace();
+                break;
+            } catch (Exception e) {
+            }
+        }
+    }
+    private void makeFocused(Component comp) {
+        if (comp.isFocusOwner()) {
+            return;
+        }
+        final Semaphore sema = new Semaphore();
+        final FocusAdapter fa = new FocusAdapter() {
+                public void focusGained(FocusEvent fe) {
+                    sema.raise();
+                }
+            };
+        comp.addFocusListener(fa);
+        comp.requestFocusInWindow();
+        if (comp.isFocusOwner()) {
+            return;
+        }
+        try {
+            sema.doWait(3000);
+        } catch (InterruptedException ie) {
+            ie.printStackTrace();
+        }
+        comp.removeFocusListener(fa);
+        if (!comp.isFocusOwner()) {
+            throw new RuntimeException("Can't make " + comp + " focused, current owner is " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+        }
+    }
+
+static class Semaphore {
+    boolean state = false;
+    int waiting = 0;
+    public Semaphore() {
+    }
+    public synchronized void doWait() throws InterruptedException {
+        if (state) {
+            return;
+        }
+        waiting++;
+        wait();
+        waiting--;
+    }
+    public synchronized void doWait(int timeout) throws InterruptedException {
+        if (state) {
+            return;
+        }
+        waiting++;
+        wait(timeout);
+        waiting--;
+    }
+    public synchronized void raise() {
+        state = true;
+        if (waiting > 0) {
+            notifyAll();
+        }
+    }
+    public synchronized boolean getState() {
+        return state;
+    }
+}
+}// class TestDialogTypeAhead
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        show();
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogTest/EnqueueWithDialogTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,239 @@
+/*
+ * 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 4799136
+@summary Tests that type-ahead for dialog works and doesn't block program
+@author Dmitry.Cherepanov@SUN.COM area=awt.focus
+@run main EnqueueWithDialogTest
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * The purpose of this test is check that the type-head
+ * works correctly on Windows. That means that the key
+ * events are not delivered until a focus transfer is
+ * completed. Another regression test EnqueueWithDialogButton
+ * doesn't work on Windows because of the bug 6347235.
+ * This test workaround the bug by means of the removing
+ * button from the dialog.
+ */
+
+public class EnqueueWithDialogTest
+{
+    static Frame f;
+    static Button b;
+    static Dialog d;
+    static CountDownLatch pressLatch = new CountDownLatch(1);
+    static CountDownLatch robotLatch = new CountDownLatch(1);
+    static volatile boolean gotFocus = false;
+    static Robot robot;
+    public static void main(String args[]) throws Exception {
+        EnqueueWithDialogTest test = new EnqueueWithDialogTest();
+        test.init();
+        test.start();
+    }
+    public void init()
+    {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+                public void eventDispatched(AWTEvent e) {
+                    if (e instanceof InputEvent){
+                        System.err.println(e.toString()+","+((InputEvent)e).getWhen());
+                    }else{
+                        System.err.println(e.toString());
+                    }
+                 }
+            }, AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
+
+
+        f = new Frame("frame");
+        f.setPreferredSize(new Dimension(100,100));
+        f.setLocation(100,50);
+        b = new Button("press");
+        d = new Dialog(f, "dialog", true);
+        d.setPreferredSize(new Dimension(70,70));
+        d.pack();
+        d.addKeyListener(new KeyAdapter() {
+                public void keyPressed(KeyEvent e) {
+                    System.err.println("DIALOG pressed: should arrive after got focus");
+                    d.dispose();
+                    f.dispose();
+                    // Typed-ahead key events should only be accepted if
+                    // they arrive after FOCUS_GAINED
+                    if (gotFocus) {
+                        pressLatch.countDown();
+                    }
+                }
+            });
+        d.addFocusListener(new FocusAdapter() {
+                public void focusGained(FocusEvent e) {
+                    gotFocus = true;
+                    System.err.println("DIALOG got focus");
+                }
+            });
+        f.add(b);
+        f.pack();
+        b.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    System.err.println(e.toString()+","+e.getWhen());
+                    System.err.println("B pressed");
+                    robotLatch.countDown();
+
+                    EventQueue.invokeLater(new Runnable() {
+                            public void run() {
+                                waitTillShown(d);
+                                EnqueueWithDialogTest.this.d.toFront();
+                                EnqueueWithDialogTest.this.moveMouseOver(d);
+                            }
+                        });
+
+                    // This will cause enqueue the following key events
+                    d.setVisible(true);
+                }
+            });
+
+    }//End  init()
+
+    public void start () throws Exception
+    {
+        try {
+            robot = new Robot();
+            //robot.setAutoDelay(50);
+        } catch (Exception e) {
+            throw new RuntimeException("Can't create robot:" + e);
+        }
+
+        f.setVisible(true);
+        waitTillShown(b);
+        System.err.println("b is shown");
+        f.toFront();
+        moveMouseOver(f);
+        robot.waitForIdle();
+        robot.delay(100);
+        makeFocused(b);
+        robot.waitForIdle();
+        robot.delay(100);
+        System.err.println("b is focused");
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        System.err.println("space typed once");
+        boolean ok = robotLatch.await(1, TimeUnit.SECONDS);
+        if(!ok) {
+            throw new RuntimeException("Was B button pressed?");
+        }
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        System.err.println("space typed twice");
+        robot.delay(500);
+        ok = pressLatch.await(3, TimeUnit.SECONDS);
+        if(!ok) {
+            throw new RuntimeException("Type-ahead doesn't work");
+        }
+
+    }// start()
+
+    private void moveMouseOver(Container c) {
+        Point p = c.getLocationOnScreen();
+        Dimension d = c.getSize();
+        robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+    }
+
+    private void waitTillShown(Component c) {
+        while (true) {
+            try {
+                Thread.sleep(100);
+                c.getLocationOnScreen();
+                break;
+            } catch (InterruptedException ie) {
+                ie.printStackTrace();
+                break;
+            } catch (Exception e) {
+            }
+        }
+    }
+    private void makeFocused(Component comp) {
+        if (comp.isFocusOwner()) {
+            return;
+        }
+        final Semaphore sema = new Semaphore();
+        final FocusAdapter fa = new FocusAdapter() {
+                public void focusGained(FocusEvent fe) {
+                    sema.raise();
+                }
+            };
+        comp.addFocusListener(fa);
+        comp.requestFocusInWindow();
+        if (comp.isFocusOwner()) {
+            return;
+        }
+        try {
+            sema.doWait(3000);
+        } catch (InterruptedException ie) {
+            ie.printStackTrace();
+        }
+        comp.removeFocusListener(fa);
+        if (!comp.isFocusOwner()) {
+            throw new RuntimeException("Can't make " + comp + " focused, current owner is " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+        }
+    }
+
+static class Semaphore {
+    boolean state = false;
+    int waiting = 0;
+    public Semaphore() {
+    }
+    public synchronized void doWait() throws InterruptedException {
+        if (state) {
+            return;
+        }
+        waiting++;
+        wait();
+        waiting--;
+    }
+    public synchronized void doWait(int timeout) throws InterruptedException {
+        if (state) {
+            return;
+        }
+        waiting++;
+        wait(timeout);
+        waiting--;
+    }
+    public synchronized void raise() {
+        state = true;
+        if (waiting > 0) {
+            notifyAll();
+        }
+    }
+    public synchronized boolean getState() {
+        return state;
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/FreezeTest/FreezeTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,219 @@
+/*
+ * 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 4799136
+@summary Tests that type-ahead for dialog works and doesn't block program
+@author Dmitry.Cherepanov@SUN.COM area=awt.focus
+@run main FreezeTest
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * Tests that type-ahead doesn't block program.
+ */
+
+public class FreezeTest
+{
+    static Frame f;
+    static Button b;
+    static Dialog d;
+    static TextField tf;
+    static CountDownLatch robotLatch = new CountDownLatch(1);
+    static Robot robot;
+    static int click_count = 100;
+    static int deliver_count = 0;
+
+    public static void main(String args[]) throws Exception {
+        FreezeTest test = new FreezeTest();
+        test.init();
+        test.start();
+    }
+    public void init()
+    {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+                public void eventDispatched(AWTEvent e) {
+                    if (e instanceof KeyEvent){
+                        deliver_count++;
+                        System.err.println("key_event# "+deliver_count);
+                    }
+
+                    if (e instanceof InputEvent){
+                        System.err.println(e.toString()+","+((InputEvent)e).getWhen());
+                    }else{
+                        System.err.println(e.toString());
+                    }
+                 }
+            }, AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
+
+
+        f = new Frame("frame");
+        b = new Button("press");
+        d = new Dialog(f, "dialog", true);
+        tf = new TextField("");
+        d.add(tf);
+        d.pack();
+
+        f.add(b);
+        f.pack();
+        b.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    System.err.println(e.toString()+","+e.getWhen());
+                    System.err.println("B pressed");
+                    robotLatch.countDown();
+
+                    EventQueue.invokeLater(new Runnable() {
+                            public void run() {
+                                waitTillShown(d);
+                                FreezeTest.this.d.toFront();
+                                FreezeTest.this.moveMouseOver(d);
+                            }
+                        });
+                    d.setVisible(true);
+                }
+            });
+
+    }//End  init()
+
+    public void start () throws Exception
+    {
+        robot = new Robot();
+
+        f.setVisible(true);
+        waitTillShown(b);
+        System.err.println("b is shown");
+        f.toFront();
+        moveMouseOver(f);
+        robot.waitForIdle();
+        makeFocused(b);
+        robot.waitForIdle();
+        System.err.println("b is focused");
+
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        boolean ok = robotLatch.await(1, TimeUnit.SECONDS);
+        if(!ok) {
+            throw new RuntimeException("Was B button pressed?");
+        }
+
+        for (int i = 0; i < click_count; i++){
+            System.err.println("click# "+(i+1));
+            robot.keyPress(KeyEvent.VK_SPACE);
+            robot.delay(10);
+            robot.keyRelease(KeyEvent.VK_SPACE);
+            robot.delay(50);
+        }
+
+        robot.waitForIdle();
+
+        int deliver_count = this.deliver_count;
+        int expected_count = (click_count + 1) * 3;
+
+        if (deliver_count != expected_count){
+            System.err.println("deliver_count = "+deliver_count+" (!="+expected_count+")");
+            throw new RuntimeException("incorrect behaviour");
+        }
+    }// start()
+
+    private void moveMouseOver(Container c) {
+        Point p = c.getLocationOnScreen();
+        Dimension d = c.getSize();
+        robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+    }
+
+    private void waitTillShown(Component c) {
+        while (true) {
+            try {
+                Thread.sleep(100);
+                c.getLocationOnScreen();
+                break;
+            } catch (InterruptedException ie) {
+                ie.printStackTrace();
+                break;
+            } catch (Exception e) {
+            }
+        }
+    }
+    private void makeFocused(Component comp) {
+        if (comp.isFocusOwner()) {
+            return;
+        }
+        final Semaphore sema = new Semaphore();
+        final FocusAdapter fa = new FocusAdapter() {
+                public void focusGained(FocusEvent fe) {
+                    sema.raise();
+                }
+            };
+        comp.addFocusListener(fa);
+        comp.requestFocusInWindow();
+        if (comp.isFocusOwner()) {
+            return;
+        }
+        try {
+            sema.doWait(3000);
+        } catch (InterruptedException ie) {
+            ie.printStackTrace();
+        }
+        comp.removeFocusListener(fa);
+        if (!comp.isFocusOwner()) {
+            throw new RuntimeException("Can't make " + comp + " focused, current owner is " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+        }
+    }
+
+static class Semaphore {
+    boolean state = false;
+    int waiting = 0;
+    public Semaphore() {
+    }
+    public synchronized void doWait() throws InterruptedException {
+        if (state) {
+            return;
+        }
+        waiting++;
+        wait();
+        waiting--;
+    }
+    public synchronized void doWait(int timeout) throws InterruptedException {
+        if (state) {
+            return;
+        }
+        waiting++;
+        wait(timeout);
+        waiting--;
+    }
+    public synchronized void raise() {
+        state = true;
+        if (waiting > 0) {
+            notifyAll();
+        }
+    }
+    public synchronized boolean getState() {
+        return state;
+    }
+}
+}
--- a/jdk/test/java/awt/List/ActionAfterRemove/ActionAfterRemove.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/List/ActionAfterRemove/ActionAfterRemove.java	Fri Dec 05 14:55:08 2014 +0300
@@ -33,27 +33,29 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
 import test.java.awt.regtesthelpers.Util;
 
 public class ActionAfterRemove
 {
     private static volatile boolean passed = true;
 
-    // handle the uncaught exception
-    public void handle(Throwable e) {
-        e.printStackTrace();
-        passed = false;
-    }
-
     public static final void main(String args[])
     {
+        // In order to handle all uncaught exceptions in the EDT
+        final Thread.UncaughtExceptionHandler eh = new Thread.UncaughtExceptionHandler()
+        {
+            @Override
+            public void uncaughtException(Thread t, Throwable e)
+            {
+                e.printStackTrace();
+                passed = false;
+            }
+        };
+
         final Frame frame = new Frame();
         final List list = new List();
         Robot robot = null;
 
-        // In order to handle all uncaught exceptions in the EDT
-        System.setProperty("sun.awt.exception.handler", "ActionAfterRemove");
 
         list.add("will be removed");
         frame.add(list);
@@ -72,9 +74,9 @@
         }
 
         Util.clickOnComp(list, robot);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
         Util.clickOnComp(list, robot);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         if (!passed){
             throw new RuntimeException("Test failed: exception was thrown on EDT.");
--- a/jdk/test/java/awt/List/EmptyListEventTest/EmptyListEventTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/List/EmptyListEventTest/EmptyListEventTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -33,7 +33,6 @@
 import javax.swing.JFrame;
 import javax.swing.JPanel;
 import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
 
 public class EmptyListEventTest {
 
@@ -41,7 +40,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -53,7 +51,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // press mouse -> ItemEvent
         Point point = getClickPoint();
@@ -61,7 +59,7 @@
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         SwingUtilities.invokeAndWait(new Runnable() {
 
@@ -71,7 +69,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != list) {
             throw new RuntimeException("Test failed - list isn't focus owner.");
@@ -80,12 +78,12 @@
         // press key ENTER -> ActionEvent
         robot.keyPress(KeyEvent.VK_ENTER);
         robot.keyRelease(KeyEvent.VK_ENTER);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // press key SPACE -> ItemEvent
         robot.keyPress(KeyEvent.VK_SPACE);
         robot.keyRelease(KeyEvent.VK_SPACE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // mouse double click -> ActionEvent
         robot.setAutoDelay(10);
@@ -93,7 +91,7 @@
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 
     private static Point getClickPoint() throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/KeyEventsTest/KeyEventsTest.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,46 @@
+<!--
+ Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ 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.
+-->
+
+<html>
+<!--  
+  @test
+  @bug 6190768 6190778
+  @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
+  @author Dmitry.Cherepanov@SUN.COM area=awt.list
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run applet KeyEventsTest.html
+  -->
+<head>
+<title>  </title>
+</head>
+<body>
+
+<h1>KeyEventsTest<br>Bug ID: 6190768 6190778 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="KeyEventsTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/KeyEventsTest/KeyEventsTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,370 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 6190768 6190778
+  @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
+  @author Dmitry.Cherepanov@SUN.COM area=awt.list
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run applet KeyEventsTest.html
+*/
+
+/**
+ * KeyEventsTest.html
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.Set;
+import java.lang.reflect.*;
+
+import jdk.testlibrary.OSInfo;
+
+public class KeyEventsTest extends Applet implements ItemListener, FocusListener, KeyListener
+{
+    TestState currentState;
+    final Object LOCK = new Object();
+    final int ACTION_TIMEOUT = 500;
+
+    List single = new List(3, false);
+    List multiple = new List(3, true);
+
+    Panel p1 = new Panel ();
+    Panel p2 = new Panel ();
+
+    public void init()
+    {
+        setLayout (new BorderLayout ());
+
+        single.add("0");
+        single.add("1");
+        single.add("2");
+        single.add("3");
+        single.add("4");
+        single.add("5");
+        single.add("6");
+        single.add("7");
+        single.add("8");
+
+        multiple.add("0");
+        multiple.add("1");
+        multiple.add("2");
+        multiple.add("3");
+        multiple.add("4");
+        multiple.add("5");
+        multiple.add("6");
+        multiple.add("7");
+        multiple.add("8");
+
+        single.addKeyListener(this);
+        single.addItemListener(this);
+        single.addFocusListener(this);
+        p1.add(single);
+        add("North", p1);
+
+        multiple.addKeyListener(this);
+        multiple.addItemListener(this);
+        multiple.addFocusListener(this);
+        p2.add(multiple);
+        add("South", p2);
+
+    }//End  init()
+
+    public void start ()
+    {
+
+        try{
+            setSize (200,200);
+            setVisible(true);
+            validate();
+
+            main(null);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("The test failed.");
+        }
+
+    }// start()
+
+    private void main(String[] args)
+      throws InterruptedException, InvocationTargetException {
+
+        doTest();
+
+        System.out.println("Test passed.");
+    }
+
+    public void itemStateChanged (ItemEvent ie) {
+        System.out.println("itemStateChanged-"+ie);
+        this.currentState.setAction(true);
+    }
+
+    public void focusGained(FocusEvent e){
+
+        synchronized (LOCK) {
+            LOCK.notifyAll();
+        }
+
+    }
+
+    public void focusLost(FocusEvent e){
+    }
+
+    public void keyPressed(KeyEvent e){
+        System.out.println("keyPressed-"+e);
+    }
+
+    public void keyReleased(KeyEvent e){
+        System.out.println("keyReleased-"+e);
+    }
+
+    public void keyTyped(KeyEvent e){
+        System.out.println("keyTyped-"+e);
+    }
+
+    private void test(TestState currentState)
+      throws InterruptedException, InvocationTargetException {
+
+        synchronized (LOCK) {
+
+            this.currentState = currentState;
+            System.out.println(this.currentState);
+
+            List list;
+            if (currentState.getMultiple()){
+                list = multiple;
+            }else{
+                list = single;
+            }
+
+            Robot r;
+            try {
+                r = new Robot();
+            } catch(AWTException e) {
+                throw new RuntimeException(e.getMessage());
+            }
+
+            r.delay(10);
+            Point loc = this.getLocationOnScreen();
+
+            r.mouseMove(loc.x+10, loc.y+10);
+            r.mousePress(InputEvent.BUTTON1_MASK);
+            r.delay(10);
+            r.mouseRelease(InputEvent.BUTTON1_MASK);
+            r.delay(10);
+
+            list.requestFocusInWindow();
+            LOCK.wait(ACTION_TIMEOUT);
+            if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != list){
+                throw new RuntimeException("Test failed - list isn't focus owner.");
+            }
+
+            list.deselect(0);
+            list.deselect(1);
+            list.deselect(2);
+            list.deselect(3);
+            list.deselect(4);
+            list.deselect(5);
+            list.deselect(6);
+            list.deselect(7);
+            list.deselect(8);
+
+            int selectIndex = 0;
+            int visibleIndex = 0;
+
+            if (currentState.getScrollMoved()){
+
+                if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
+                    currentState.getKeyID() == KeyEvent.VK_HOME){
+                    selectIndex = 8;
+                    visibleIndex = 8;
+                }else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
+                    currentState.getKeyID() == KeyEvent.VK_END){
+                    selectIndex = 0;
+                    visibleIndex = 0;
+                }
+
+            }else{
+
+                if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
+                    currentState.getKeyID() == KeyEvent.VK_HOME){
+
+                    if (currentState.getSelectedMoved()){
+                        selectIndex = 1;
+                        visibleIndex = 0;
+                    }else{
+                        selectIndex = 0;
+                        visibleIndex = 0;
+                    }
+
+                }else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
+                    currentState.getKeyID() == KeyEvent.VK_END){
+
+                    if (currentState.getSelectedMoved()){
+                        selectIndex = 7;
+                        visibleIndex = 8;
+                    }else{
+                        selectIndex = 8;
+                        visibleIndex = 8;
+                    }
+
+                }
+
+            }
+
+            list.select(selectIndex);
+            list.makeVisible(visibleIndex);
+
+            r.delay(10);
+
+            if (currentState.getKeyID() == KeyEvent.VK_HOME ||
+                currentState.getKeyID() == KeyEvent.VK_END){
+                r.keyPress(KeyEvent.VK_CONTROL);
+            }
+
+            r.delay(10);
+            r.keyPress(currentState.getKeyID());
+            r.delay(10);
+            r.keyRelease(currentState.getKeyID());
+            r.delay(10);
+
+            if (currentState.getKeyID() == KeyEvent.VK_HOME ||
+                currentState.getKeyID() == KeyEvent.VK_END){
+                r.keyRelease(KeyEvent.VK_CONTROL);
+            }
+
+            r.waitForIdle();
+            r.delay(200);
+
+            if (currentState.getTemplate() != currentState.getAction())
+                throw new RuntimeException("Test failed.");
+
+        }
+
+    }
+
+    private void doTest()
+      throws InterruptedException, InvocationTargetException {
+
+        boolean isWin = false;
+        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+            isWin = true;
+        }else if(OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+            System.out.println("Not for OS X");
+            return;
+        }
+
+        System.out.println("multiple? selectedMoved? ?scrollMoved keyID? template? action?");
+        test(new TestState(false, false, false, KeyEvent.VK_PAGE_UP, isWin?false:false));
+        // SelectedMoved (false) != ScrollMoved (true) for single list not emulated
+        test(new TestState(false, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
+        test(new TestState(false, true, true, KeyEvent.VK_PAGE_UP, isWin?true:true));
+        test(new TestState(true, false, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
+        test(new TestState(true, false, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
+        test(new TestState(true, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
+        test(new TestState(true, true, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
+
+        test(new TestState(false, false, false, KeyEvent.VK_PAGE_DOWN, isWin?false:false));
+        test(new TestState(false, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+        test(new TestState(false, true, true, KeyEvent.VK_PAGE_DOWN, isWin?true:true));
+        test(new TestState(true, false, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+        test(new TestState(true, false, true, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+        test(new TestState(true, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+        test(new TestState(true, true, true, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+
+        test(new TestState(false, false, false, KeyEvent.VK_HOME, isWin?false:true));
+        test(new TestState(false, true, false, KeyEvent.VK_HOME, isWin?true:true));
+        test(new TestState(false, true, true, KeyEvent.VK_HOME, isWin?true:true));
+        test(new TestState(true, false, false, KeyEvent.VK_HOME, isWin?true:false));
+        test(new TestState(true, false, true, KeyEvent.VK_HOME, isWin?true:false));
+        test(new TestState(true, true, false, KeyEvent.VK_HOME, isWin?true:false));
+        test(new TestState(true, true, true, KeyEvent.VK_HOME, isWin?true:false));
+
+        test(new TestState(false, false, false, KeyEvent.VK_END, isWin?false:true));
+        test(new TestState(false, true, false, KeyEvent.VK_END, isWin?true:true));
+        test(new TestState(false, true, true, KeyEvent.VK_END, isWin?true:true));
+        test(new TestState(true, false, false, KeyEvent.VK_END, isWin?true:false));
+        test(new TestState(true, false, true, KeyEvent.VK_END, isWin?true:false));
+        test(new TestState(true, true, false, KeyEvent.VK_END, isWin?true:false));
+        test(new TestState(true, true, true, KeyEvent.VK_END, isWin?true:false));
+
+    }
+}// class KeyEventsTest
+
+class TestState{
+
+    private boolean multiple;
+    // after key pressing selected item moved
+    private final boolean selectedMoved;
+    // after key pressing scroll moved
+    private final boolean scrollMoved;
+    private final int keyID;
+    private final boolean template;
+    private boolean action;
+
+    public TestState(boolean multiple, boolean selectedMoved, boolean scrollMoved, int keyID, boolean template){
+        this.multiple = multiple;
+        this.selectedMoved = selectedMoved;
+        this.scrollMoved = scrollMoved;
+        this.keyID = keyID;
+        this.template = template;
+        this.action = false;
+    }
+
+    public boolean getMultiple(){
+        return multiple;
+    }
+    public boolean getSelectedMoved(){
+        return selectedMoved;
+    }
+
+    public boolean getScrollMoved(){
+        return scrollMoved;
+    }
+
+    public int getKeyID(){
+        return keyID;
+    }
+
+    public boolean getTemplate(){
+        return template;
+    }
+
+    public boolean getAction(){
+        return action;
+    }
+
+    public void setAction(boolean action){
+        this.action = action;
+    }
+
+    public String toString(){
+        return multiple + "," + selectedMoved + "," + scrollMoved + "," + keyID + "," + template + "," + action;
+    }
+}// TestState
--- a/jdk/test/java/awt/List/NofocusListDblClickTest/NofocusListDblClickTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/List/NofocusListDblClickTest/NofocusListDblClickTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -32,14 +32,12 @@
 import java.awt.event.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
 
 public class NofocusListDblClickTest {
     static final int EXPECTED_ACTION_COUNT = 2;
     static Robot robot;
     static final AtomicInteger actionPerformed = new AtomicInteger(0);
     static List lst;
-    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
     public static void main(String[] args) throws Exception {
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -47,16 +45,16 @@
                 createAndShowGUI();
             }
         });
-        toolkit.realSync();
+        robot = new Robot();
+        robot.setAutoDelay(50);
+        robot.waitForIdle();
         Thread.sleep(1000);
 
-        robot = new Robot();
-        robot.setAutoDelay(50);
         // ACTION_PERFORMED event happens only on even clicks
         clickTwiceOn(lst);
         Thread.sleep(500);
         clickTwiceOn(lst);
-        toolkit.realSync();
+        robot.waitForIdle();
         Thread.sleep(1000);
 
         synchronized (actionPerformed) {
--- a/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java	Fri Dec 05 14:55:08 2014 +0300
@@ -33,7 +33,6 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
 import test.java.awt.regtesthelpers.Util;
 
 public class ScrollOut
@@ -54,13 +53,13 @@
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
 
         try{
             robot = new Robot();
         }catch(AWTException e){
             throw new RuntimeException(e);
         }
+        robot.waitForIdle();
 
         //Drag from center to the outside on left
         Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,
@@ -68,16 +67,16 @@
         Point to = new Point(list.getLocationOnScreen().x - 30,
                              from.y);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
         Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         //Drag from center to the outside on up
         to = new Point(from.x,
                        list.getLocationOnScreen().y - 50);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
         Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
 
     }//End  init()
--- a/jdk/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -26,6 +26,8 @@
   @bug 6246467
   @summary List does not honor user specified background, foreground colors on XToolkit
   @author Dmitry Cherepanov  area=awt.list
+  @library ../../../../lib/testlibrary
+  @build ExtendedRobot
   @run main SetBackgroundTest
 */
 
@@ -37,29 +39,12 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
 
 public class SetBackgroundTest
 {
 
-    private static void init()
-    {
-        String[] instructions =
-        {
-            "This is an AUTOMATIC test, simply wait until it is done.",
-            "The result (passed or failed) will be shown in the",
-            "message window below."
-        };
-        Sysout.createDialog( );
-        Sysout.printInstructions( instructions );
-
-        test();
-
-        SetBackgroundTest.pass();
-    }//End  init()
-
     private static boolean isXAWT = (Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.XToolkit"));
-    private static Robot robot = null;
+    private static ExtendedRobot robot = null;
     private static Frame frame = null;
 
     private static final Color color = Color.red;
@@ -71,24 +56,24 @@
         canvas.setBackground(color);
         frame.add(canvas, BorderLayout.CENTER);
         frame.validate();
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle(500);
 
         Point loc = canvas.getLocationOnScreen();
         Color robotColor = robot.getPixelColor(loc.x + canvas.getWidth()/2, loc.y + canvas.getHeight()/2);
         roughColor = robotColor;
 
-        Sysout.println(" --- init rough color ... ");
-        Sysout.println("     color = "+color);
-        Sysout.println("     roughColor = "+roughColor);
+        System.out.println(" --- init rough color ... ");
+        System.out.println("     color = "+color);
+        System.out.println("     roughColor = "+roughColor);
 
         frame.remove(canvas);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle(500);
     }
 
 
     private static void test() {
         if (!isXAWT){
-            Sysout.println(" this is XAWT-only test. ");
+            System.out.println(" this is XAWT-only test. ");
             return;
         }
 
@@ -97,14 +82,15 @@
         frame.setLayout(new BorderLayout());
         frame.setVisible(true);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
 
         try{
-            robot = new Robot();
+            robot = new ExtendedRobot();
         }catch(AWTException e){
             throw new RuntimeException(e.getMessage());
         }
 
+        robot.waitForIdle(500);
+
         initRoughColor();
         Component[] components = new Component[] {
             new Button(), new Checkbox(), new Label(), new List(3, false),
@@ -115,6 +101,7 @@
             testComponent(new Panel(), component, color);
         }
 
+        robot.waitForIdle(1500);
         frame.dispose();
     }
 
@@ -127,327 +114,31 @@
         frame.add(container, BorderLayout.CENTER);
         frame.add("Center", container);
         frame.validate();
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle(500);
 
         Point loc = component.getLocationOnScreen();
         Color robotColor = robot.getPixelColor(loc.x + component.getWidth()/2, loc.y + component.getHeight()/2);
 
-        Sysout.println(" --- test ... ");
-        Sysout.println("     container = "+container);
-        Sysout.println("     component = "+component);
-        Sysout.println("     color = "+color);
-        Sysout.println("     roughColor = "+roughColor);
-        Sysout.println("     robotColor = "+robotColor);
+        System.out.println(" --- test ... ");
+        System.out.println("     container = "+container);
+        System.out.println("     component = "+component);
+        System.out.println("     color = "+color);
+        System.out.println("     roughColor = "+roughColor);
+        System.out.println("     robotColor = "+robotColor);
 
         if(robotColor.getRGB() != roughColor.getRGB()){
             throw new RuntimeException(" the case failed. ");
         } else {
-            Sysout.println(" the case passed. ");
+            System.out.println(" the case passed. ");
         }
 
         container.remove(component);
         frame.remove(container);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle(500);
     }
-
-
-    /*****************************************************
-     * Standard Test Machinery Section
-     * DO NOT modify anything in this section -- it's a
-     * standard chunk of code which has all of the
-     * synchronisation necessary for the test harness.
-     * By keeping it the same in all tests, it is easier
-     * to read and understand someone else's test, as
-     * well as insuring that all tests behave correctly
-     * with the test harness.
-     * There is a section following this for test-
-     * classes
-     ******************************************************/
-    private static boolean theTestPassed = false;
-    private static boolean testGeneratedInterrupt = false;
-    private static String failureMessage = "";
-
-    private static Thread mainThread = null;
-
-    private static int sleepTime = 300000;
-
-    // Not sure about what happens if multiple of this test are
-    //  instantiated in the same VM.  Being static (and using
-    //  static vars), it aint gonna work.  Not worrying about
-    //  it for now.
-    public static void main( String args[] ) throws InterruptedException
+    public static void main( String args[] ) throws Exception
     {
-        mainThread = Thread.currentThread();
-        try
-        {
-            init();
-        }
-        catch( TestPassedException e )
-        {
-            //The test passed, so just return from main and harness will
-            // interepret this return as a pass
-            return;
-        }
-        //At this point, neither test pass nor test fail has been
-        // called -- either would have thrown an exception and ended the
-        // test, so we know we have multiple threads.
-
-        //Test involves other threads, so sleep and wait for them to
-        // called pass() or fail()
-        try
-        {
-            Thread.sleep( sleepTime );
-            //Timed out, so fail the test
-            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
-        }
-        catch (InterruptedException e)
-        {
-            //The test harness may have interrupted the test.  If so, rethrow the exception
-            // so that the harness gets it and deals with it.
-            if( ! testGeneratedInterrupt ) throw e;
-
-            //reset flag in case hit this code more than once for some reason (just safety)
-            testGeneratedInterrupt = false;
-
-            if ( theTestPassed == false )
-            {
-                throw new RuntimeException( failureMessage );
-            }
-        }
-
-    }//main
-
-    public static synchronized void setTimeoutTo( int seconds )
-    {
-        sleepTime = seconds * 1000;
+        test();
     }
-
-    public static synchronized void pass()
-    {
-        Sysout.println( "The test passed." );
-        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
-        //first check if this is executing in main thread
-        if ( mainThread == Thread.currentThread() )
-        {
-            //Still in the main thread, so set the flag just for kicks,
-            // and throw a test passed exception which will be caught
-            // and end the test.
-            theTestPassed = true;
-            throw new TestPassedException();
-        }
-        theTestPassed = true;
-        testGeneratedInterrupt = true;
-        mainThread.interrupt();
-    }//pass()
-
-    public static synchronized void fail()
-    {
-        //test writer didn't specify why test failed, so give generic
-        fail( "it just plain failed! :-)" );
-    }
-
-    public static synchronized void fail( String whyFailed )
-    {
-        Sysout.println( "The test failed: " + whyFailed );
-        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
-        //check if this called from main thread
-        if ( mainThread == Thread.currentThread() )
-        {
-            //If main thread, fail now 'cause not sleeping
-            throw new RuntimeException( whyFailed );
-        }
-        theTestPassed = false;
-        testGeneratedInterrupt = true;
-        failureMessage = whyFailed;
-        mainThread.interrupt();
-    }//fail()
-
-}// class AutomaticMainTest
-
-//This exception is used to exit from any level of call nesting
-// when it's determined that the test has passed, and immediately
-// end the test.
-class TestPassedException extends RuntimeException
-{
 }
 
-//*********** End Standard Test Machinery Section **********
-
-
-//************ Begin classes defined for the test ****************
-
-// if want to make listeners, here is the recommended place for them, then instantiate
-//  them in init()
-
-/* Example of a class which may be written as part of a test
-class NewClass implements anInterface
- {
-   static int newVar = 0;
-
-   public void eventDispatched(AWTEvent e)
-    {
-      //Counting events to see if we get enough
-      eventCount++;
-
-      if( eventCount == 20 )
-       {
-         //got enough events, so pass
-
-         AutomaticMainTest.pass();
-       }
-      else if( tries == 20 )
-       {
-         //tried too many times without getting enough events so fail
-
-         AutomaticMainTest.fail();
-       }
-
-    }// eventDispatched()
-
- }// NewClass class
-
-*/
-
-
-//************** End classes defined for the test *******************
-
-
-
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
-  chunk of code whose purpose is to make user
-  interaction uniform, and thereby make it simpler
-  to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
-  for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
-  WithInstructions method.  Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
-  with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
-  as standalone.
- */
-
-class Sysout
-{
-    private static TestDialog dialog;
-
-    public static void createDialogWithInstructions( String[] instructions )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        dialog.printInstructions( instructions );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-    public static void createDialog( )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        String[] defInstr = { "Instructions will appear here. ", "" } ;
-        dialog.printInstructions( defInstr );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-
-    public static void printInstructions( String[] instructions )
-    {
-        dialog.printInstructions( instructions );
-    }
-
-
-    public static void println( String messageIn )
-    {
-        dialog.displayMessage( messageIn );
-        System.out.println(messageIn);
-    }
-
-}// Sysout  class
-
-/**
-  This is part of the standard test machinery.  It provides a place for the
-   test instructions to be displayed, and a place for interactive messages
-   to the user to be displayed.
-  To have the test instructions displayed, see Sysout.
-  To have a message to the user be displayed, see Sysout.
-  Do not call anything in this dialog directly.
-  */
-class TestDialog extends Dialog
-{
-
-    TextArea instructionsText;
-    TextArea messageText;
-    int maxStringLength = 80;
-
-    //DO NOT call this directly, go through Sysout
-    public TestDialog( Frame frame, String name )
-    {
-        super( frame, name );
-        int scrollBoth = TextArea.SCROLLBARS_BOTH;
-        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
-        add( "North", instructionsText );
-
-        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
-        add("Center", messageText);
-
-        pack();
-
-        setVisible(true);
-    }// TestDialog()
-
-    //DO NOT call this directly, go through Sysout
-    public void printInstructions( String[] instructions )
-    {
-        //Clear out any current instructions
-        instructionsText.setText( "" );
-
-        //Go down array of instruction strings
-
-        String printStr, remainingStr;
-        for( int i=0; i < instructions.length; i++ )
-        {
-            //chop up each into pieces maxSringLength long
-            remainingStr = instructions[ i ];
-            while( remainingStr.length() > 0 )
-            {
-                //if longer than max then chop off first max chars to print
-                if( remainingStr.length() >= maxStringLength )
-                {
-                    //Try to chop on a word boundary
-                    int posOfSpace = remainingStr.
-                        lastIndexOf( ' ', maxStringLength - 1 );
-
-                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
-                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
-                    remainingStr = remainingStr.substring( posOfSpace + 1 );
-                }
-                //else just print
-                else
-                {
-                    printStr = remainingStr;
-                    remainingStr = "";
-                }
-
-                instructionsText.append( printStr + "\n" );
-
-            }// while
-
-        }// for
-
-    }//printInstructions()
-
-    //DO NOT call this directly, go through Sysout
-    public void displayMessage( String messageIn )
-    {
-        messageText.append( messageIn + "\n" );
-        System.out.println(messageIn);
-    }
-
-}// TestDialog  class
--- a/jdk/test/java/awt/MenuBar/8007006/bug8007006.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/MenuBar/8007006/bug8007006.java	Fri Dec 05 14:55:08 2014 +0300
@@ -26,35 +26,38 @@
  * @bug 8007006
  * @summary [macosx] Closing subwindow loses main window menus.
  * @author Leonid Romanov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot jdk.testlibrary.OSInfo
  * @run main bug8007006
  */
 
-import sun.awt.SunToolkit;
 import java.awt.*;
 import java.awt.event.*;
 
+import jdk.testlibrary.OSInfo;
+
 public class bug8007006 {
     private static Frame frame1;
     private static Frame frame2;
 
     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;
         }
 
         System.setProperty("apple.laf.useScreenMenuBar", "true");
 
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(50);
+
         createAndShowGUI();
-        sleep(1500);
+        robot.waitForIdle(1500);
 
         frame2.dispose();
-        sleep(1500);
 
-        SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
+        robot.waitForIdle(1500);
 
-        Robot robot = new Robot();
-        robot.setAutoDelay(50);
 
         // open "Apple" menu (the leftmost one)
         robot.keyPress(KeyEvent.VK_META);
@@ -74,7 +77,7 @@
         robot.keyPress(KeyEvent.VK_ENTER);
         robot.keyRelease(KeyEvent.VK_ENTER);
 
-        sleep(0);
+        robot.waitForIdle();
 
         MenuBar mbar = frame1.getMenuBar();
         Menu menu = mbar.getMenu(0);
@@ -112,13 +115,4 @@
         return mbar;
     }
 
-    private static void sleep(int ms) {
-        SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
-        tk.realSync();
-
-        try {
-            Thread.sleep(ms);
-        } catch (Exception ignore) {
-        }
-    }
 }
--- a/jdk/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java	Fri Dec 05 14:55:08 2014 +0300
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.Button;
 import java.awt.CardLayout;
 import java.awt.Font;
@@ -31,16 +29,19 @@
 import java.awt.MenuBar;
 import java.awt.Point;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.InputEvent;
 
+import jdk.testlibrary.OSInfo;
+
 /**
  * @test
  * @bug 6263470
  * @summary Tries to change font of MenuBar. Test passes if the font has changed
  * fails otherwise.
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
  * @author Vyacheslav.Baranov: area=menu
  * @run main MenuBarSetFont
  */
@@ -66,7 +67,7 @@
 
     public static void main(final String[] args) throws Exception {
 
-        if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.MACOSX) {
+        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
             System.err.println("This test is not for OS X. Menu.setFont() is not supported on OS X.");
             return;
         }
@@ -75,13 +76,16 @@
         frame.setMenuBar(mb);
         mb.setFont(new Font("Helvetica", Font.ITALIC, 5));
 
+        final Robot r = new Robot();
+        r.setAutoDelay(200);
+
         final Button button = new Button("Click Me");
         button.addActionListener(new Listener());
         frame.setLayout(new CardLayout());
         frame.add(button, "First");
         frame.setSize(400, 400);
         frame.setVisible(true);
-        sleep();
+        sleep(r);
 
         final int fInsets = frame.getInsets().top;  //Frame insets without menu.
         addMenu();
@@ -96,24 +100,23 @@
 
         mb.remove(0);
         frame.validate();
-        sleep();
+        sleep(r);
 
         // Test execution.
         // On XToolkit, menubar font should be changed to 60.
         // On WToolkit, menubar font should be changed to default and menubar
         // should be splitted in 2 rows.
         mb.setFont(new Font("Helvetica", Font.ITALIC, 60));
-        sleep();
 
-        final Robot r = new Robot();
-        r.setAutoDelay(200);
+        sleep(r);
+
         final Point pt = frame.getLocation();
         r.mouseMove(pt.x + frame.getWidth() / 2,
                     pt.y + fMenuInsets + menuBarHeight / 2);
         r.mousePress(InputEvent.BUTTON1_MASK);
         r.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        sleep();
+        sleep(r);
         frame.dispose();
 
         if (clicked) {
@@ -121,8 +124,8 @@
         }
     }
 
-    private static void sleep() {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+    private static void sleep(Robot robot) {
+        robot.waitForIdle();
         try {
             Thread.sleep(500L);
         } catch (InterruptedException ignored) {
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java	Fri Dec 05 14:55:08 2014 +0300
@@ -29,7 +29,7 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import javax.swing.*;
-import sun.awt.*;
+import sun.awt.EmbeddedFrame;
 import java.io.*;
 import test.java.awt.regtesthelpers.Util;
 
@@ -141,7 +141,6 @@
     public void getVerifyColor() {
         try {
             final int size = 200;
-            final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
             final Point[] p = new Point[1];
             SwingUtilities.invokeAndWait(new Runnable() {
                 public void run(){
@@ -155,7 +154,7 @@
                 }
             });
             Robot robot = new Robot();
-            toolkit.realSync();
+            robot.waitForIdle();
             Thread.sleep(ROBOT_DELAY);
             AWT_VERIFY_COLOR = robot.getPixelColor(p[0].x+size/2, p[0].y+size/2);
             System.out.println("Color will be compared with " + AWT_VERIFY_COLOR + " instead of " + AWT_BACKGROUND_COLOR);
@@ -434,6 +433,11 @@
     protected Component currentAwtControl;
 
     private void testComponent(Component component) throws InterruptedException, InvocationTargetException {
+        Robot robot = null;
+        try {
+            robot = new Robot();
+        }catch(Exception ignorex) {
+        }
         currentAwtControl = component;
         System.out.println("Testing " + currentAwtControl.getClass().getSimpleName());
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -444,7 +448,7 @@
         if (component != null) {
             Util.waitTillShown(component);
         }
-        Util.waitForIdle(null);
+        Util.waitForIdle(robot);
         try {
             Thread.sleep(500); // wait for graphic effects on systems like Win7
         } catch (InterruptedException ex) {
@@ -461,6 +465,11 @@
     }
 
     private void testEmbeddedFrame() throws InvocationTargetException, InterruptedException {
+        Robot robot = null;
+        try {
+            robot = new Robot();
+        }catch(Exception ignorex) {
+        }
         System.out.println("Testing EmbeddedFrame");
         currentAwtControl = null;
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -468,7 +477,7 @@
                 prepareControls();
             }
         });
-        Util.waitForIdle(null);
+        Util.waitForIdle(robot);
         try {
             Thread.sleep(500); // wait for graphic effects on systems like Win7
         } catch (InterruptedException ex) {
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Fri Dec 05 14:55:08 2014 +0300
@@ -135,7 +135,7 @@
 
         // get coord
         Point lLoc = !debug ? testedComponent.getLocationOnScreen() : new Point(70, 30);
-        Util.waitForIdle(null);
+        Util.waitForIdle(robot);
         /* this is a workaround for certain jtreg(?) focus issue:
            tests fail starting after failing mixing tests but always pass alone.
          */
@@ -152,7 +152,7 @@
         }
 
         clickAndBlink(robot, lLoc);
-        Util.waitForIdle(null);
+        Util.waitForIdle(robot);
 
         return wasLWClicked;
     }
--- a/jdk/test/java/awt/Modal/ModalDialogOrderingTest/ModalDialogOrderingTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Modal/ModalDialogOrderingTest/ModalDialogOrderingTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -29,13 +29,13 @@
 import java.awt.Toolkit;
 import java.awt.event.InputEvent;
 
-import sun.awt.SunToolkit;
-
 /**
  * @test
  * @bug 8008728
  * @summary [macosx] Swing. JDialog. Modal dialog goes to background
  * @author Alexandr Scherbatiy
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
  * @run main ModalDialogOrderingTest
  */
 public class ModalDialogOrderingTest {
@@ -69,12 +69,12 @@
 
     private static void runTest(Dialog dialog, Frame frame) {
         try {
-            Robot robot = new Robot();
+            ExtendedRobot robot = new ExtendedRobot();
             robot.setAutoDelay(50);
             robot.mouseMove(300, 300);
 
             while (!dialog.isVisible()) {
-                sleep();
+                robot.waitForIdle(1000);
             }
 
             Rectangle dialogBounds = dialog.getBounds();
@@ -89,30 +89,23 @@
             robot.mouseMove(clickX, clickY);
             robot.mousePress(InputEvent.BUTTON1_MASK);
             robot.mouseRelease(InputEvent.BUTTON1_MASK);
-            sleep();
+            robot.waitForIdle(1000);
 
             int colorX = dialogBounds.x + dialogBounds.width / 2;
             int colorY = dialogBounds.y + dialogBounds.height / 2;
 
             Color color = robot.getPixelColor(colorX, colorY);
 
-            dialog.dispose();
-            frame.dispose();
 
             if (!DIALOG_COLOR.equals(color)) {
                 throw new RuntimeException("The frame is on top"
                         + " of the modal dialog!");
+            }else{
+                frame.dispose();
+                dialog.dispose();
             }
         } catch (Exception ex) {
             throw new RuntimeException(ex);
         }
     }
-
-    private static void sleep() {
-        try {
-            Thread.sleep(1000);
-        } catch (InterruptedException ignored) {
-        }
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
-    }
 }
--- a/jdk/test/java/awt/Modal/ModalInternalFrameTest/ModalInternalFrameTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Modal/ModalInternalFrameTest/ModalInternalFrameTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -34,11 +34,10 @@
 
 import javax.swing.*;
 
-import sun.awt.*;
-
 public class ModalInternalFrameTest
 {
     private boolean passed = true;
+    private static Robot r;
 
     private JDesktopPane pane1;
     private JDesktopPane pane2;
@@ -139,13 +138,12 @@
         r.mouseMove(p.x, p.y);
         r.mousePress(InputEvent.BUTTON1_MASK);
         r.mouseRelease(InputEvent.BUTTON1_MASK);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        r.waitForIdle();
     }
 
     private void start()
         throws Exception
     {
-        Robot r = new Robot();
         r.setAutoDelay(200);
 
         unblocked1 = false;
@@ -193,6 +191,7 @@
     public static void main(String[] args)
         throws Exception
     {
+        r = new Robot();
         test = new ModalInternalFrameTest();
         SwingUtilities.invokeAndWait(new Runnable()
         {
@@ -201,7 +200,7 @@
                 test.init();
             }
         });
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        r.waitForIdle();
         SwingUtilities.invokeAndWait(new Runnable()
         {
             public void run()
--- a/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -37,7 +37,6 @@
 import javax.swing.*;
 
 import java.util.concurrent.*;
-import sun.awt.SunToolkit;
 
 import test.java.awt.regtesthelpers.Util;
 
@@ -57,7 +56,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -69,7 +67,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
 
@@ -82,7 +80,7 @@
 
         robot.mouseMove(pointToClick.x, pointToClick.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) {
             throw new RuntimeException(
@@ -100,7 +98,7 @@
         });
 
         robot.mouseMove(450, pointToClick.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
             throw new RuntimeException(
@@ -108,7 +106,7 @@
         }
 
         robot.mouseMove(450, pointToDrag.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
             throw new RuntimeException(
@@ -121,7 +119,7 @@
         }
 
         robot.mouseMove(pointToDrag.y, pointToDrag.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (buttonMouseEnteredCount != 1 && buttonMouseExitedCount != 0) {
             throw new RuntimeException(
@@ -129,7 +127,7 @@
         }
 
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (labelMouseReleasedCount != 1) {
             throw new RuntimeException("No MouseReleased event on label!");
--- a/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -38,7 +38,6 @@
 import javax.swing.*;
 
 import java.util.concurrent.*;
-import sun.awt.SunToolkit;
 
 import test.java.awt.regtesthelpers.Util;
 
@@ -54,7 +53,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -66,7 +64,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
 
@@ -79,7 +77,7 @@
 
         robot.mouseMove(pointToClick.x, pointToClick.y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (dragWindowMouseEnteredCount != 1) {
             throw new RuntimeException("No MouseEntered event on Drag Window!");
@@ -95,14 +93,14 @@
         });
 
         robot.mouseMove(pointToDrag.x, pointToDrag.y);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (buttonMouseEnteredCount != 0) {
             throw new RuntimeException("Extra MouseEntered event on button!");
         }
 
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (labelMouseReleasedCount != 1) {
             throw new RuntimeException("No MouseReleased event on label!");
--- a/jdk/test/java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -28,15 +28,10 @@
  * @author  alexandr.scherbatiy area=awt.event
  * @run main ResizingFrameTest
  */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import sun.awt.SunToolkit;
 
 public class ResizingFrameTest {
 
@@ -46,10 +41,10 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
         robot.mouseMove(100, 100);
+        robot.delay(200);
 
         // create a frame under the mouse cursor
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -61,7 +56,8 @@
         });
 
 
-        toolkit.realSync();
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 1 || mouseExitedCount != 0) {
             throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -76,11 +72,11 @@
             }
         });
 
-        toolkit.realSync();
-        robot.delay(200);
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 1 || mouseExitedCount != 1) {
-            throw new RuntimeException("No Mouse Entered/Exited events!");
+            throw new RuntimeException("No Mouse Entered/Exited events! "+mouseEnteredCount+", "+mouseExitedCount);
         }
 
         // deiconify frame
@@ -92,8 +88,8 @@
             }
         });
 
-        toolkit.realSync();
-        robot.delay(200);
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 2 || mouseExitedCount != 1) {
             throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -101,8 +97,8 @@
 
         // move the mouse out of the frame
         robot.mouseMove(500, 500);
-        toolkit.realSync();
-        robot.delay(200);
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 2 || mouseExitedCount != 2) {
             throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -117,8 +113,8 @@
             }
         });
 
-        toolkit.realSync();
-        robot.delay(200);
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 3 || mouseExitedCount != 2) {
             throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -134,8 +130,8 @@
             }
         });
 
-        toolkit.realSync();
-        robot.delay(200);
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 3 || mouseExitedCount != 3) {
             throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -151,8 +147,8 @@
             }
         });
 
-        toolkit.realSync();
-        robot.delay(200);
+        robot.waitForIdle();
+        robot.delay(1000);
 
         if (mouseEnteredCount != 4 || mouseExitedCount != 3) {
             throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -167,7 +163,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         robot.delay(400);
 
         if (mouseEnteredCount != 4 || mouseExitedCount != 4) {
@@ -183,7 +179,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         robot.delay(200);
 
         if (mouseEnteredCount != 5 || mouseExitedCount != 4) {
@@ -199,7 +195,7 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
         robot.delay(400);
 
 
@@ -229,4 +225,4 @@
 
         frame.setVisible(true);
     }
-}
\ No newline at end of file
+}
--- a/jdk/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -27,8 +27,6 @@
  * @summary Tests JComboBox selection via the mouse
  * @author Dmitry Markov
  */
-import sun.awt.SunToolkit;
-
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicComboPopup;
 import javax.swing.plaf.basic.ComboPopup;
@@ -41,14 +39,12 @@
 public class MouseComboBoxTest {
     private static final String[] items = {"One", "Two", "Three", "Four", "Five"};
 
-    private static SunToolkit toolkit = null;
     private static Robot robot = null;
     private static JFrame frame = null;
     private static JComboBox comboBox = null;
     private static MyComboBoxUI comboBoxUI = null;
 
     public static void main(String[] args) throws Exception {
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         robot = new Robot();
         robot.setAutoDelay(50);
 
@@ -59,19 +55,19 @@
                 createAndShowGUI();
             }
         });
-        toolkit.realSync();
+        robot.waitForIdle();
 
         for (int i = 0; i < items.length; i++) {
             // Open popup
             robot.keyPress(KeyEvent.VK_DOWN);
             robot.keyRelease(KeyEvent.VK_DOWN);
-            toolkit.realSync();
+            robot.waitForIdle();
 
             Point point = getItemPointToClick(i);
             robot.mouseMove(point.x, point.y);
             robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
             robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
-            toolkit.realSync();
+            robot.waitForIdle();
 
             if (i != getSelectedIndex()) {
                 throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
--- a/jdk/test/java/awt/Multiscreen/MouseEventTest/MouseEventTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Multiscreen/MouseEventTest/MouseEventTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -28,8 +28,6 @@
   @run main MouseEventTest
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
@@ -37,8 +35,8 @@
 public class MouseEventTest {
     static volatile boolean crossed = false;
 
-    static void sleep() throws InterruptedException {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+    static void sleep(Robot robot) throws InterruptedException {
+        robot.waitForIdle();
         Thread.sleep(500);
     }
 
@@ -64,7 +62,7 @@
             frame.setLocation(screen.x + 200, screen.y + 200);
             frame.setBackground(Color.YELLOW);
             frame.setVisible(true);
-            sleep();
+            sleep(robot);
 
             Point loc = frame.getLocationOnScreen();
             Dimension size = frame.getSize();
@@ -86,7 +84,7 @@
             robot.mouseMove(point.x - 1, point.y - 1);
             robot.mouseMove(point.x, point.y);
 
-            sleep();
+            sleep(robot);
             frame.dispose();
 
             if (!crossed) {
--- a/jdk/test/java/awt/Paint/PaintNativeOnUpdate.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Paint/PaintNativeOnUpdate.java	Fri Dec 05 14:55:08 2014 +0300
@@ -28,21 +28,22 @@
 import java.awt.Graphics;
 import java.awt.Label;
 import java.awt.Point;
-import java.awt.Robot;
-import java.awt.Toolkit;
-
-import sun.awt.SunToolkit;
 
 /**
  * @test
  * @bug 7157680
+ * @library ../../../lib/testlibrary
+ * @build ExtendedRobot
  * @author Sergey Bylokhov
+ @ @run main PaintNativeOnUpdate
  */
 public final class PaintNativeOnUpdate extends Label {
 
     private boolean fullUpdate = true;
 
     public static void main(final String[] args) throws AWTException {
+        ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(50);
         final Frame frame = new Frame();
         final Component label = new PaintNativeOnUpdate();
         frame.setBackground(Color.RED);
@@ -51,14 +52,12 @@
         frame.setUndecorated(true);
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
-        sleep();
+        robot.waitForIdle(1000);
         label.repaint();// first paint
-        sleep();
+        robot.waitForIdle(1000);
         label.repaint();// incremental paint
-        sleep();
+        robot.waitForIdle(1000);
 
-        Robot robot = new Robot();
-        robot.setAutoDelay(50);
         Point point = label.getLocationOnScreen();
         Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                           point.y + label.getHeight() / 2);
@@ -87,12 +86,4 @@
     public void paint(final Graphics g) {
         // Do nothing
     }
-
-    private static void sleep() {
-        try {
-            ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
-            Thread.sleep(1000);
-        } catch (InterruptedException ignored) {
-        }
-    }
 }
--- a/jdk/test/java/awt/Robot/CtorTest/CtorTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Robot/CtorTest/CtorTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -38,8 +38,6 @@
 import java.awt.*;
 import java.awt.event.*;
 
-import sun.awt.SunToolkit;
-
 public class CtorTest
 {
     public static void main(String []s) throws Exception
@@ -57,7 +55,7 @@
         frame.setBounds(100, 100, 100, 100);
         frame.setVisible(true);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         // click in the middle of the frame
         robot.mouseMove(150, 150);
@@ -66,6 +64,6 @@
         robot.delay(50);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextArea/ScrollbarIntersectionTest/ScrollbarIntersectionTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,207 @@
+/*
+ * 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 6429174
+  @summary Tests that mouse click at the are of intersection of two
+   scrollbars for text area doesn't trigger any scrolling
+  @author artem.ananiev@sun.com: area=awt.text
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
+  @run main ScrollbarIntersectionTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import jdk.testlibrary.OSInfo;
+
+
+public class ScrollbarIntersectionTest
+{
+    private static void init()
+    {
+
+        Frame f = new Frame("F");
+        f.setBounds(100, 100, 480, 360);
+        f.setLayout(new BorderLayout());
+
+        TextArea ta = new TextArea(null, 8, 24, TextArea.SCROLLBARS_BOTH);
+        // append several lines to show vertical scrollbar
+        for (int i = 0; i < 128; i++)
+        {
+            ta.append("" + i + "\n");
+        }
+        // and some characters into the last line for horizontal scrollbar
+        for (int i = 0; i < 128; i++)
+        {
+            ta.append("" + i);
+        }
+        ta.append("\n");
+        f.add(ta);
+
+        f.setVisible(true);
+
+        Robot r = null;
+        try
+        {
+            r = new Robot();
+            r.setAutoDelay(20);
+        }
+        catch (Exception z)
+        {
+            z.printStackTrace(System.err);
+            fail(z.getMessage());
+            return;
+        }
+        r.waitForIdle();
+
+        ta.setCaretPosition(0);
+        r.waitForIdle();
+
+        Point p = ta.getLocationOnScreen();
+        Dimension d = ta.getSize();
+
+        int fh = 8;
+        Graphics g = ta.getGraphics();
+        try
+        {
+            FontMetrics fm = g.getFontMetrics();
+            fh = fm.getHeight();
+        }
+        finally
+        {
+            if (g != null)
+            {
+                g.dispose();
+            }
+        };
+
+        r.mouseMove(p.x + d.width - 2, p.y + d.height - 2);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+        r.waitForIdle();
+
+        // select 1st line in the text area
+        r.mouseMove(p.x + 2, p.y + 2 + fh / 2);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+        for (int i = 0; i < d.width - 4; i += 4)
+        {
+            r.mouseMove(p.x + 2 + i, p.y + 2 + fh / 2);
+        }
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+        r.waitForIdle();
+
+        String sel = ta.getSelectedText();
+        System.err.println("Selected text: " + sel);
+        if ((sel == null) || !sel.startsWith("0"))
+        {
+            fail("Test FAILED: TextArea is scrolled");
+            return;
+        }
+
+        pass();
+    }
+
+    private static boolean theTestPassed = false;
+    private static boolean testGeneratedInterrupt = false;
+    private static String failureMessage = "";
+
+    private static Thread mainThread = null;
+
+    private static int sleepTime = 300000;
+
+    public static void main( String args[] ) throws InterruptedException
+    {
+        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+            // On OS X, this area is commandeered by the system,
+            // and frame would be wildly resized
+            System.out.println("Not for OS X");
+            return;
+        }
+        mainThread = Thread.currentThread();
+        try
+        {
+            init();
+        }
+        catch( TestPassedException e )
+        {
+            return;
+        }
+
+        try
+        {
+            Thread.sleep( sleepTime );
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+        }
+        catch (InterruptedException e)
+        {
+            if( ! testGeneratedInterrupt ) throw e;
+
+            testGeneratedInterrupt = false;
+
+            if ( theTestPassed == false )
+            {
+                throw new RuntimeException( failureMessage );
+            }
+        }
+    }
+
+    public static synchronized void setTimeoutTo( int seconds )
+    {
+        sleepTime = seconds * 1000;
+    }
+
+    public static synchronized void pass()
+    {
+        if ( mainThread == Thread.currentThread() )
+        {
+            theTestPassed = true;
+            throw new TestPassedException();
+        }
+        theTestPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail()
+    {
+        fail( "it just plain failed! :-)" );
+    }
+
+    public static synchronized void fail( String whyFailed )
+    {
+        if ( mainThread == Thread.currentThread() )
+        {
+            throw new RuntimeException( whyFailed );
+        }
+        theTestPassed = false;
+        testGeneratedInterrupt = true;
+        failureMessage = whyFailed;
+        mainThread.interrupt();
+    }
+}
+
+class TestPassedException extends RuntimeException
+{
+}
--- a/jdk/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -27,9 +27,7 @@
 import java.awt.Point;
 import java.awt.Robot;
 import java.awt.TextField;
-import java.awt.Toolkit;
 import java.awt.event.InputEvent;
-import sun.awt.SunToolkit;
 
 /**
  * @test
@@ -54,19 +52,18 @@
         frame.add(panel);
         frame.setVisible(true);
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
-
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
+        robot.waitForIdle();
+
         Point point = textField.getLocationOnScreen();
         int x = point.x + textField.getWidth() / 2;
         int y = point.y + textField.getHeight() / 2;
         robot.mouseMove(x, y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.mousePress(InputEvent.BUTTON1_MASK);
         int N = 10;
@@ -76,7 +73,7 @@
             robot.mouseMove(x, y);
         }
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (!textField.getSelectedText().endsWith(LAST_WORD)) {
             throw new RuntimeException("Last word is not selected!");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/RealSync/Test.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2005, 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 6252005
+  @summary Tests that realSync feature works
+  @author denis.mikhalkin: area=awt.toolkit
+  @run main/timeout=6000 Test
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.LinkedList;
+import java.util.Collections;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import javax.swing.*;
+import java.awt.image.*;
+import javax.imageio.*;
+import java.io.*;
+
+/**
+ * Tests various problematic areas and how they are fixed using real-sync API:
+ * - requesting focus
+ * - showing and robot mouse pressing
+ * - showing and getting location on screen
+ * - showing and typing
+ */
+
+public class Test {
+    private static boolean doRealSync = true;
+    private static boolean someFailed = false;
+    private static Robot robot;
+    public static void main(String[] args) {
+        installListeners();
+
+        try {
+            robot = new Robot();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+
+
+        int count = 100;
+        String method = null;
+        if (args.length != 0) {
+            try {
+                count = Integer.parseInt(args[0]);
+            } catch (NumberFormatException nfe) {
+                method = args[0];
+                count = 1;
+            }
+        }
+        while (count > 0 && !someFailed) {
+            run(method);
+            gc();
+            count--;
+        }
+
+        System.err.println("Total results: " + (someFailed? ("some tests failed (" + count + ")"): "ALL TESTS PASSED!!!"));
+    }
+
+    private static void gc() {
+        System.gc();
+        sleep(50);
+        System.gc();
+        Thread.yield();
+        System.gc();
+    }
+
+    private static void sleep(int time) {
+        try {
+            Thread.sleep(time);
+        } catch (InterruptedException ie) {
+        }
+    }
+
+    private static java.util.List<Object> events = Collections.synchronizedList(new LinkedList<Object>());
+
+    private static class TestFailureException extends RuntimeException {
+    }
+
+    public static void run(String method) {
+        Class cl = Test.class;
+        for (Method m : cl.getMethods()) {
+            if (Modifier.isStatic(m.getModifiers()) && m.getName().startsWith("test") && method == null ||
+                (method != null && method.equals(m.getName()))) {
+                realSync(null);
+                events.clear();
+                try {
+                    m.invoke(null);
+                } catch (TestFailureException e) {
+                    // Do nothing
+                } catch (Exception e) {
+                    fail(e);
+                }
+                reportErrors(m);
+            }
+        }
+    }
+
+    private static java.util.List<Object> errors = Collections.synchronizedList(new LinkedList<Object>());
+    public static void reportErrors(Method m) {
+        realSync(null);
+        if (errors.size() == 0) {
+//             System.err.println("Test passed: " + m.getName());
+//             System.err.println("------------------------------------------------------\nEvents for " + m.getName());
+//             for (Object e : events) {
+//                 System.err.println(e);
+//             }
+            return;
+        }
+
+        someFailed = true;
+        System.err.println("Test failed: " + m.getName());
+        for (Object error : errors) {
+            if (error instanceof Throwable) {
+                ((Throwable)error).printStackTrace();
+            } else {
+                System.err.println("Cause: " + error);
+            }
+        }
+        System.err.println("Events:");
+        synchronized(events) {
+            for (Object e : events) {
+                System.err.println(e);
+            }
+        }
+        errors.clear();
+        System.exit(1);
+    }
+
+    public static void asser(boolean value) {
+        if (!value) {
+            fail("Test failed");
+        }
+    }
+    public static void asser(boolean value, String msg) {
+        if (!value) {
+            fail(msg);
+        }
+    }
+    static int screenNum = 0;
+    public static void fail(Object cause) {
+        synchronized (events) {
+            events.add("FAILURE MOMENT");
+        }
+        errors.add(cause);
+        errors.add("- Focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+        errors.add("- Focused window: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow());
+//         try {
+//             Robot r = new Robot();
+//             BufferedImage image = r.createScreenCapture(new Rectangle(0, 0, 1024, 768));
+//             ImageIO.write(image, "GIF", new File("/tmp/screen" + screenNum + ".gif"));
+//             screenNum++;
+//             image.flush();
+//         } catch (Exception e) {
+//         }
+    }
+
+    public static void _test1() {
+        Frame f = new Frame();
+        f.setLocation(100, 100);
+
+        f.setVisible(true);
+
+        Point loc = new Point(100, 100);
+        robot.mouseMove(loc.x+30, loc.y+40);
+
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        try {
+            Thread.sleep(3000);
+        } catch (InterruptedException ie) {
+        }
+    }
+
+    public static void testType() {
+        Frame f = new Frame("testType");
+        f.setLayout(new BorderLayout());
+        TextField b = new TextField();
+        f.add(b, BorderLayout.CENTER);
+        f.setBounds(100, 100, 200, 200);
+
+        f.setVisible(true);
+        realSync(f);
+
+        f.toFront();
+        realSync(f);
+        b.requestFocus();
+        realSync(f);
+        asser(b.isFocusOwner(), "Couldn't focus text field");
+
+        robot.keyPress(KeyEvent.VK_A);
+        robot.keyRelease(KeyEvent.VK_A);
+        realSync(f);
+        asser("a".equals(b.getText()), "Wrong text: " + b.getText());
+        f.dispose();
+    }
+
+    public static void testTypeSwing() {
+        JFrame f = new JFrame("testTypeSwing");
+        f.setLayout(new BorderLayout());
+        JTextField b = new JTextField();
+        f.add(b, BorderLayout.CENTER);
+        f.setBounds(100, 100, 200, 200);
+
+        f.setVisible(true);
+        realSync(f);
+
+        f.toFront();
+        realSync(f);
+        b.requestFocus();
+        realSync(f);
+        asser(b.isFocusOwner(), "Couldn't focus text field");
+
+        robot.keyPress(KeyEvent.VK_A);
+        robot.keyRelease(KeyEvent.VK_A);
+        realSync(f);
+        asser("a".equals(b.getText()), "Wrong text: " + b.getText());
+        f.dispose();
+    }
+
+    private static boolean pressed;
+    public static void testPress() {
+        Frame f = new Frame("testPress");
+        f.setLayout(new FlowLayout());
+        Button b = new Button("b");
+        b.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    pressed = true;
+                }
+            });
+        f.add(b);
+        f.setBounds(100, 100, 200, 200);
+
+        f.setVisible(true);
+        realSync(f);
+
+        Point loc = b.getLocationOnScreen();
+        events.add("Pressing at " + loc);
+        robot.mouseMove(loc.x+3, loc.y+3);
+        pressed = false;
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        realSync(f);
+        asser(pressed, "Not pressed");
+        f.dispose();
+    }
+
+    public static void testPressSwing() {
+        JFrame f = new JFrame("testPressSwing");
+        f.setLayout(new FlowLayout());
+        JButton b = new JButton("b");
+        b.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    pressed = true;
+                }
+            });
+        f.add(b);
+        f.setBounds(100, 100, 200, 200);
+
+        f.setVisible(true);
+        realSync(f);
+
+        Point loc = b.getLocationOnScreen();
+        events.add("Pressing at " + loc);
+        robot.mouseMove(loc.x+3, loc.y+3);
+        pressed = false;
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        realSync(f);
+        asser(pressed, "Not pressed");
+        f.dispose();
+    }
+
+    public static void testFocus0() {
+        Frame f = new Frame("testFocus0");
+        f.setLayout(new FlowLayout());
+        Button b1 = new Button("b1");
+        Button b2 = new Button("b2");
+        f.add(b1);
+        f.add(b2);
+        f.setBounds(100, 100, 200, 200);
+        f.setVisible(true);
+        realSync(f);
+        f.toFront();
+        realSync(f);
+        asser(b1.isFocusOwner(), "B1 didn't get focus");
+        b2.requestFocus();
+        realSync(f);
+        asser(b2.isFocusOwner(), "Couldn't focus b2");
+        f.dispose();
+    }
+
+    public static void testFocus1() {
+        Frame f = new Frame("testFocus1");
+        f.setLayout(new FlowLayout());
+        Button b1 = new Button("b1");
+        f.add(b1);
+        f.setBounds(100, 100, 200, 200);
+        f.setVisible(true);
+        realSync(f);
+        f.toFront();
+        realSync(f);
+        asser(b1.isFocusOwner(), "B1 didn't get focus");
+        f.dispose();
+    }
+
+    public static void testFocus2() {
+        Frame f = new Frame("testFocus2");
+        f.setLayout(new FlowLayout());
+        Button b1 = new Button("b1");
+        Button b2 = new Button("b2");
+        f.add(b1);
+        f.add(b2);
+        f.setBounds(100, 100, 200, 200);
+        f.setVisible(true);
+        realSync(f);
+        f.toFront();
+        realSync(f);
+        b2.requestFocus();
+        realSync(f);
+        if (!b2.isFocusOwner()) {
+            fail("1: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+        } else {
+            // Half passed
+            b1.requestFocus();
+            realSync(f);
+            asser(b1.isFocusOwner(), "B1 couldn't get focus");
+        }
+        f.dispose();
+    }
+
+    public static void testFocus2Swing() {
+        JFrame f = new JFrame("testFocus2Swing");
+        f.setLayout(new FlowLayout());
+        JButton b1 = new JButton("b1");
+        JButton b2 = new JButton("b2");
+        f.add(b1);
+        f.add(b2);
+        f.setBounds(100, 100, 200, 200);
+        f.setVisible(true);
+        realSync(f);
+        f.toFront();
+        realSync(f);
+        b2.requestFocus();
+        realSync(f);
+        if (!b2.isFocusOwner()) {
+            fail("1: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+        } else {
+            // Half passed
+            b1.requestFocus();
+            realSync(f);
+            asser(b1.isFocusOwner(), "B1 couldn't get focus");
+        }
+        f.dispose();
+    }
+
+    public static void realSync(Window w) {
+        if (doRealSync) {
+            ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        }
+    }
+
+    public static void installListeners() {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+                public void eventDispatched(AWTEvent e) {
+                    synchronized(events) {
+                        events.add(e);
+                    }
+                }
+            }, 0xffff & ~AWTEvent.HIERARCHY_EVENT_MASK);
+//         ((XToolkit)Toolkit.getDefaultToolkit()).addXEventListener(new XToolkit.XEventListener() {
+//                 public void eventProcessed(IXAnyEvent e) {
+//                     synchronized(events) {
+//                         events.add(e);
+//                     }
+//                 }
+//             });
+    }
+}
--- a/jdk/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java	Fri Dec 05 14:55:08 2014 +0300
@@ -40,7 +40,6 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.util.concurrent.atomic.AtomicBoolean;
-import sun.awt.SunToolkit;
 
 
 //*** global search and replace TestAlwaysOnTopBeforeShow with name of the test ***
@@ -53,6 +52,7 @@
     private static AtomicBoolean focused = new AtomicBoolean();
     private static AtomicBoolean pressed = new AtomicBoolean();
     private static volatile Object pressedTarget;
+    private static Robot robot = null;
     private static void init()
     {
         //*** Create instructions for the user here ***
@@ -123,10 +123,13 @@
     }//End  init()
 
     private static void waitForIdle(int mls) {
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
         try {
+            if(robot == null) {
+                robot = new Robot();
+            }
+            robot.waitForIdle();
             Thread.sleep(mls);
-        } catch (InterruptedException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
--- a/jdk/test/java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java	Fri Dec 05 14:55:08 2014 +0300
@@ -27,16 +27,16 @@
 import java.awt.Graphics;
 import java.awt.Point;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.Window;
 
-import sun.awt.SunToolkit;
-
 /**
  * @test
  * @bug 8001472
  * @summary Background of the window should not depend from the paint()/update()
  * @author Sergey Bylokhov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main BackgroundIsNotUpdated
  */
 public final class BackgroundIsNotUpdated extends Window {
 
@@ -59,11 +59,12 @@
         window.setSize(300, 300);
         window.setLocationRelativeTo(null);
         window.setVisible(true);
-        sleep();
+        window.requestFocus();
+        final ExtendedRobot robot = new ExtendedRobot();
+        robot.setAutoDelay(200);
+        robot.waitForIdle(1000);
         window.setBackground(Color.GREEN);
-        sleep();
-        final Robot robot = new Robot();
-        robot.setAutoDelay(200);
+        robot.waitForIdle(1000);
         Point point = window.getLocationOnScreen();
         Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                           point.y + window.getHeight() / 2);
@@ -73,12 +74,4 @@
                     "Expected: " + Color.GREEN + " , Actual: " + color);
         }
     }
-
-    private static void sleep() {
-        try {
-            ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
-            Thread.sleep(1000);
-        } catch (InterruptedException ignored) {
-        }
-    }
 }
--- a/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -65,7 +65,6 @@
     public static void main(String[] args)
         throws Exception
     {
-        sun.awt.SunToolkit tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit();
 
         final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         for (GraphicsDevice gd : ge.getScreenDevices()) {
@@ -96,7 +95,7 @@
                 initAndShowGUI();
             }
         });
-        tk.realSync();
+        r.waitForIdle();
 
         if (!paintComponentCalled) {
             throw new RuntimeException("Test FAILED: panel's paintComponent() method is not called");
--- a/jdk/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -25,16 +25,16 @@
   @test
   @bug 4397404 4720930
   @summary tests that images of all supported native image formats are transfered properly
+  @library ../../../../lib/testlibrary
   @library ../../regtesthelpers/process/
-  @build ProcessResults ProcessCommunicator
+  @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator
   @author gas@sparc.spb.su area=Clipboard
   @run main ImageTransferTest
 */
 
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
 import test.java.awt.regtesthelpers.process.ProcessResults;
+import jdk.testlibrary.OSInfo;
 
 import java.awt.*;
 import java.awt.datatransfer.DataFlavor;
@@ -105,11 +105,15 @@
 
 
 class Util {
+    private static Robot srobot = null;
     public static void sync() {
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
         try {
+            if(srobot == null) {
+                srobot = new Robot();
+            }
+            srobot.waitForIdle();
             Thread.sleep(500);
-        } catch (InterruptedException e) {
+        } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
--- a/jdk/test/java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -34,7 +34,6 @@
 import java.awt.Color;
 import java.awt.Point;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.dnd.DnDConstants;
 import java.awt.dnd.DropTarget;
 import java.awt.dnd.DropTargetAdapter;
@@ -49,7 +48,6 @@
 import javax.swing.JTextArea;
 import javax.swing.SwingUtilities;
 
-import sun.awt.SunToolkit;
 import test.java.awt.regtesthelpers.Util;
 
 public class MissingDragExitEventTest {
@@ -108,7 +106,7 @@
             } finally {
                 r.mouseRelease(InputEvent.BUTTON1_MASK);
             }
-            sleep();
+            sleep(r);
 
             if (FAILED || !MOUSE_ENTERED || !MOUSE_ENTERED_DT || !MOUSE_EXIT
                     || !MOUSE_EXIT_TD) {
@@ -121,12 +119,12 @@
         }
     }
 
-    private static void sleep() {
+    private static void sleep(Robot robot) {
         try {
             Thread.sleep(10000);
         } catch (InterruptedException ignored) {
         }
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
     }
 
     static class TestdropTargetListener extends DropTargetAdapter {
--- a/jdk/test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.event.AWTEventListener;
 import java.awt.event.InputEvent;
@@ -71,7 +69,6 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Frame frame = new Frame();
 
         try {
@@ -79,9 +76,9 @@
             frame.setBounds(300, 300, 300, 300);
             frame.add(b);
             frame.setVisible(true);
-            toolkit.realSync();
 
             Robot robot = new Robot();
+            robot.waitForIdle();
             robot.mouseMove((int)frame.getLocationOnScreen().getX() + 150,
                     (int)frame.getLocationOnScreen().getY() + 150);
 
@@ -104,7 +101,7 @@
             System.out.println("Clicking mouse done: " + eventsCount + " events.");
 
             b.requestFocusInWindow();
-            toolkit.realSync();
+            robot.waitForIdle();
 
             eventsCount = 0;
             System.out.println("Typing a key...");
--- a/jdk/test/java/awt/event/KeyEvent/8020209/bug8020209.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/KeyEvent/8020209/bug8020209.java	Fri Dec 05 14:55:08 2014 +0300
@@ -26,13 +26,16 @@
  * @bug 8020209
  * @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
  * @author leonid.romanov@oracle.com
+ * @library ../../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
  * @run main bug8020209
  */
 
-import sun.awt.*;
 import java.awt.*;
 import java.awt.event.*;
 
+import jdk.testlibrary.OSInfo;
+
 public class bug8020209 {
     static volatile int listenerCallCounter = 0;
 
@@ -43,19 +46,18 @@
     };
 
     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;
         }
 
         System.setProperty("apple.laf.useScreenMenuBar", "true");
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
         createAndShowGUI();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         for (int i = 0; i < keyStrokes.length; ++i) {
             AWTKeyStroke ks = keyStrokes[i];
@@ -68,7 +70,7 @@
 
             robot.keyRelease(modKeyCode);
 
-            toolkit.realSync();
+            robot.waitForIdle();
 
             if (listenerCallCounter != 4) {
                 throw new Exception("Test failed: KeyListener for '" + ks.toString() +
--- a/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java	Fri Dec 05 14:55:08 2014 +0300
@@ -26,18 +26,19 @@
  * @bug 7199180
  * @summary [macosx] Dead keys handling for input methods
  * @author alexandr.scherbatiy area=awt.event
+ * @library ../../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
  * @run main DeadKeyMacOSXInputText
  */
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.event.KeyEvent;
 import javax.swing.JTextField;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
 
 public class DeadKeyMacOSXInputText {
 
-    private static SunToolkit toolkit;
     private static volatile int state = 0;
 
     public static void main(String[] args) throws Exception {
@@ -46,11 +47,10 @@
             return;
         }
 
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
-        createAndShowGUI();
+        createAndShowGUI(robot);
 
         // Pressed keys: Alt + E + A
         // Results:  ALT + VK_DEAD_ACUTE + a with accute accent
@@ -61,14 +61,14 @@
 
         robot.keyPress(KeyEvent.VK_A);
         robot.keyRelease(KeyEvent.VK_A);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         if (state != 3) {
             throw new RuntimeException("Wrong number of key events.");
         }
     }
 
-    static void createAndShowGUI() {
+    static void createAndShowGUI(Robot robot) {
         Frame frame = new Frame();
         frame.setSize(300, 300);
         Panel panel = new Panel(new BorderLayout());
@@ -77,10 +77,10 @@
         panel.add(textField, BorderLayout.CENTER);
         frame.add(panel);
         frame.setVisible(true);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         textField.requestFocusInWindow();
-        toolkit.realSync();
+        robot.waitForIdle();
 
     }
 
--- a/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java	Fri Dec 05 14:55:08 2014 +0300
@@ -24,9 +24,7 @@
 import java.awt.Frame;
 import java.awt.Robot;
 import java.awt.TextField;
-import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
-import sun.awt.SunToolkit;
 /*
  * @test
  * @bug 8013849
@@ -39,25 +37,25 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Frame frame = new Frame();
         frame.setSize(300, 200);
 
         TextField textField = new TextField();
         frame.add(textField);
 
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
         frame.setVisible(true);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         textField.requestFocus();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         // Check that the system assertion dialog does not block Java
-        Robot robot = new Robot();
-        robot.setAutoDelay(50);
         robot.keyPress(KeyEvent.VK_A);
         robot.keyRelease(KeyEvent.VK_A);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         frame.setVisible(false);
         frame.dispose();
--- a/jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java	Fri Dec 05 14:55:08 2014 +0300
@@ -26,18 +26,19 @@
  * @bug 7196547
  * @summary Dead Key implementation for KeyEvent on Mac OS X
  * @author alexandr.scherbatiy area=awt.event
+ * @library ../../../../../lib/testlibrary
+ * @build  jdk.testlibrary.OSInfo
  * @run main deadKeyMacOSX
  */
 
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.event.KeyEvent;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
 
 public class deadKeyMacOSX {
 
-    private static SunToolkit toolkit;
     private static volatile int state = 0;
 
     public static void main(String[] args) throws Exception {
@@ -46,11 +47,10 @@
             return;
         }
 
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
-        createAndShowGUI();
+        createAndShowGUI(robot);
 
         // Pressed keys: Alt + E + A
         // Results:  ALT + VK_DEAD_ACUTE + a with accute accent
@@ -67,17 +67,17 @@
         }
     }
 
-    static void createAndShowGUI() {
+    static void createAndShowGUI(Robot robot) {
         Frame frame = new Frame();
         frame.setSize(300, 300);
         Panel panel = new Panel();
         panel.addKeyListener(new DeadKeyListener());
         frame.add(panel);
         frame.setVisible(true);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         panel.requestFocusInWindow();
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 
     static class DeadKeyListener extends KeyAdapter {
--- a/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -23,17 +23,16 @@
 
 import java.awt.Frame;
 import java.awt.Robot;
-import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyAdapter;
-import sun.awt.ExtendedKeyCodes;
-import sun.awt.SunToolkit;
 
 /*
  * @test
  * @bug 8007156 8025126
  * @summary Extended key code is not set for a key event
  * @author Alexandr Scherbatiy
+ * @library ../../../../../lib/testlibrary
+ * @build ExtendedRobot
  * @run main ExtendedKeyCodeTest
  */
 public class ExtendedKeyCodeTest {
@@ -42,8 +41,7 @@
     private static volatile int eventsCount = 0;
 
     public static void main(String[] args) throws Exception {
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        Robot robot = new Robot();
+        ExtendedRobot robot = new ExtendedRobot();
         robot.setAutoDelay(50);
 
         Frame frame = new Frame();
@@ -55,23 +53,23 @@
             public void keyPressed(KeyEvent e) {
                 eventsCount++;
                 setExtendedKeyCode = setExtendedKeyCode && (e.getExtendedKeyCode()
-                        == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar()));
+                        == KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()));
             }
 
             @Override
             public void keyReleased(KeyEvent e) {
                 eventsCount++;
                 setExtendedKeyCode = setExtendedKeyCode && (e.getExtendedKeyCode()
-                        == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar()));
+                        == KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()));
             }
         });
 
         frame.setVisible(true);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(KeyEvent.VK_D);
         robot.keyRelease(KeyEvent.VK_D);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         frame.dispose();
 
@@ -92,11 +90,11 @@
         });
 
         frame.setVisible(true);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         robot.keyPress(KeyEvent.VK_LEFT);
         robot.keyRelease(KeyEvent.VK_LEFT);
-        toolkit.realSync();
+        robot.waitForIdle();
         frame.dispose();
 
         if (!setExtendedKeyCode) {
--- a/jdk/test/java/awt/event/KeyEvent/KeyChar/KeyCharTest.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/KeyEvent/KeyChar/KeyCharTest.java	Fri Dec 05 14:55:08 2014 +0300
@@ -28,7 +28,6 @@
 import java.awt.event.AWTEventListener;
 import java.awt.event.KeyEvent;
 import java.util.Locale;
-import sun.awt.SunToolkit;
 
 /*
  * @test
@@ -59,18 +58,18 @@
 
     public static void main(String[] args) throws Exception {
 
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         Frame frame = new Frame();
         frame.setSize(300, 300);
         frame.setVisible(true);
-        toolkit.realSync();
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+        robot.waitForIdle();
 
-        Robot robot = new Robot();
 
         robot.keyPress(KeyEvent.VK_DELETE);
         robot.keyRelease(KeyEvent.VK_DELETE);
-        toolkit.realSync();
+        robot.waitForIdle();
 
         frame.dispose();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 1998, 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 1.2 98/08/05
+  @bug 4515763
+  @summary Tests that clicking mouse and pressing keys generates correct amount of click-counts
+  @author andrei.dmitriev: area=awt.mouse
+  @run main ClickDuringKeypress
+*/
+
+/**
+ * ClickDuringKeypress.java
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+public class ClickDuringKeypress implements MouseListener
+ {
+   //Declare things used in the test, like buttons and labels here
+   final static int CLICKCOUNT = 10;
+   final static int DOUBLE_CLICK_AUTO_DELAY = 10;
+   volatile int lastClickCount = 0;
+   volatile boolean clicked = false;
+   volatile boolean ready = false;
+
+   Frame frame;
+   Robot robot;
+
+   public void init()
+    {
+      //Create instructions for the user here, as well as set up
+      // the environment -- set the layout manager, add buttons,
+      // etc.
+
+      frame = new Frame("ClickDuringKeypress");
+      frame.addMouseListener(this);
+      frame.addWindowListener(new WindowAdapter() {
+          public void windowActivated(WindowEvent e) {
+              synchronized(ClickDuringKeypress.this) {
+                  ready = true;
+                  ClickDuringKeypress.this.notifyAll();
+              }
+          }
+      });
+      frame.setBounds(0, 0, 400, 400);
+
+      start();
+
+    }//End  init()
+
+   public void start ()
+    {
+      try {
+        robot = new Robot();
+      } catch (AWTException e) {
+        System.out.println("Could not create Robot.");
+        throw new RuntimeException("Couldn't create Robot.  Test fails");
+      }
+
+      robot.mouseMove(200, 200);
+      frame.show();
+
+      synchronized(this) {
+          try {
+              if (!ready) {
+                  wait(10000);
+              }
+          } catch (InterruptedException ex) {
+          }
+          if (!ready) {
+              System.out.println("Not Activated. Test fails");
+              throw new RuntimeException("Not Activated. Test fails");
+          }
+      }
+
+      doTest();
+
+      //What would normally go into main() will probably go here.
+      //Use System.out.println for diagnostic messages that you want
+      //to read after the test is done.
+      //Use Sysout.println for messages you want the tester to read.
+
+    }// start()
+
+    // Mouse should be over the Frame by this point
+    private void doTest() {
+      robot.setAutoDelay(2000);
+      robot.waitForIdle();
+      robot.keyPress(KeyEvent.VK_B);
+      robot.mousePress(InputEvent.BUTTON1_MASK);
+      robot.delay(10);
+      robot.mouseRelease(InputEvent.BUTTON1_MASK);
+      // Should trigger mouseClicked
+      robot.keyRelease(KeyEvent.VK_B);
+      robot.delay(1000);
+
+      robot.setAutoDelay(DOUBLE_CLICK_AUTO_DELAY);
+      for (int i = 0; i < CLICKCOUNT / 2; i++) {
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(10);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.keyPress(KeyEvent.VK_B);
+        robot.delay(10);
+        robot.keyRelease(KeyEvent.VK_B);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(10);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+      }
+      robot.waitForIdle();
+      // check results
+      robot.delay(200);
+      if (!clicked) {
+          System.out.println("No MOUSE_CLICKED events received.  Test fails.");
+          throw new RuntimeException("No MOUSE_CLICKED events received.  Test fails.");
+      }
+      if (lastClickCount != CLICKCOUNT) {
+          System.out.println("Actual click count: " + lastClickCount + " does not match expected click count: " + CLICKCOUNT + ".  Test fails");
+          throw new RuntimeException("Actual click count: " + lastClickCount + " does not match expected click count: " + CLICKCOUNT + ".  Test fails");
+
+      }
+      // else test passes.
+    }
+
+    public void mouseEntered(MouseEvent e) {}
+    public void mouseExited(MouseEvent e) {}
+    public void mousePressed(MouseEvent e) {}
+    public void mouseReleased(MouseEvent e) {}
+    public void mouseClicked(MouseEvent e) {
+        System.out.println(e.toString());
+        clicked = true;
+        lastClickCount = e.getClickCount();
+    }
+
+     public static void main(String[] args) {
+         new ClickDuringKeypress().init();
+     }
+
+ }// class ClickDuringKeypress
--- a/jdk/test/java/awt/event/MouseWheelEvent/DisabledComponent/DisabledComponent.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/event/MouseWheelEvent/DisabledComponent/DisabledComponent.java	Fri Dec 05 14:55:08 2014 +0300
@@ -24,9 +24,9 @@
 /*
   @test
   @bug 6847958
-  @library ../../../regtesthelpers
   @summary MouseWheel event is getting triggered for the disabled Textarea in jdk7 b60 pit build.
   @author Dmitry Cherepanov: area=awt.event
+  @library ../../../regtesthelpers
   @build Util
   @run main DisabledComponent
 */
@@ -40,8 +40,6 @@
 import java.awt.*;
 import java.awt.event.*;
 
-import sun.awt.SunToolkit;
-
 import test.java.awt.regtesthelpers.Util;
 
 public class DisabledComponent
@@ -72,21 +70,21 @@
                 }
             };
 
+        Robot robot = new Robot();
+
 
         list.addMouseWheelListener(listener);
         textArea.addMouseWheelListener(listener);
 
         frame.setVisible(true);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
-
-        Robot robot = new Robot();
+        robot.waitForIdle();
 
         // point and wheel on the list
         Util.pointOnComp(list, robot);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         robot.mouseWheel(2);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         // disable the text area
         System.err.println(" disable text area ");
@@ -95,10 +93,10 @@
 
         // point and wheel on the text area
         Util.pointOnComp(textArea, robot);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         robot.mouseWheel(2);
-        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
 
         if (!passed) {
             throw new RuntimeException(" wrong wheel events ");
--- a/jdk/test/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java	Fri Dec 05 14:55:08 2014 +0300
@@ -27,7 +27,7 @@
   @summary REGRESSION: Popup menus dont respond to selections when extend outside Applet
   @author oleg.sukhodolsky area=awt.grab
   @library ../../regtesthelpers
-  @build Util
+  @build Util UtilInternal
   @run main EmbeddedFrameTest1
 */
 
@@ -44,6 +44,7 @@
 import java.awt.Robot;
 import java.awt.TextArea;
 import java.awt.Toolkit;
+import java.awt.AWTException;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -51,40 +52,21 @@
 import javax.swing.JButton;
 import javax.swing.JPopupMenu;
 
-import sun.awt.SunToolkit;
-
 import test.java.awt.regtesthelpers.Util;
+import test.java.awt.regtesthelpers.UtilInternal;
 
 public class EmbeddedFrameTest1
 {
-    private static void init()
+    public static void main( String args[] ) throws AWTException
     {
-        //*** Create instructions for the user here ***
-
-        String[] instructions = {
-            "This is an AUTOMATIC test, simply wait until it is done.",
-            "The result (passed or failed) will be shown in the",
-            "message window below."
-        };
-
-        Sysout.createDialog( );
-        Sysout.printInstructions( instructions );
-
-        SunToolkit tk = (SunToolkit) Toolkit.getDefaultToolkit();
-        if ("sun.awt.motif.MToolkit".equals(tk.getClass().getName())) {
-            System.out.println("We shouldn't test MToolkit.");
-            EmbeddedFrameTest1.pass();
-            return;
-        }
-
         try {
             final Frame frame = new Frame("AWT Frame");
             frame.pack();
             frame.setSize(200,200);
 
-            final Frame embedded_frame = Util.createEmbeddedFrame(frame);
+            final Frame embedded_frame = UtilInternal.createEmbeddedFrame(frame);
             embedded_frame.setSize(200, 200);
-            Sysout.println("embedded_frame = " + embedded_frame);
+            System.out.println("embedded_frame = " + embedded_frame);
 
             final JPopupMenu menu = new JPopupMenu();
             JButton item = new JButton("A button in popup");
@@ -110,12 +92,12 @@
             p.validate();
             frame.setVisible(true);
             Robot robot = new Robot();
-            tk.realSync();
+            robot.waitForIdle();
             Util.clickOnComp(btn, robot);
-            tk.realSync();
+            robot.waitForIdle();
 
             Util.clickOnComp(item, robot);
-            tk.realSync();
+            robot.waitForIdle();
             if (item.getMousePosition() == null) {
                 throw new RuntimeException("Popup was not closed (mouse above it)");
             }
@@ -124,268 +106,7 @@
             frame.dispose();
         } catch (Throwable thr) {
             thr.printStackTrace();
-            EmbeddedFrameTest1.fail("TEST FAILED: " + thr);
-        }
-        EmbeddedFrameTest1.pass();
-    }//End  init()
-
-    /*****************************************************
-     * Standard Test Machinery Section
-     * DO NOT modify anything in this section -- it's a
-     * standard chunk of code which has all of the
-     * synchronisation necessary for the test harness.
-     * By keeping it the same in all tests, it is easier
-     * to read and understand someone else's test, as
-     * well as insuring that all tests behave correctly
-     * with the test harness.
-     * There is a section following this for test-
-     * classes
-     ******************************************************/
-    private static boolean theTestPassed = false;
-    private static boolean testGeneratedInterrupt = false;
-    private static String failureMessage = "";
-
-    private static Thread mainThread = null;
-
-    private static int sleepTime = 300000;
-
-    // Not sure about what happens if multiple of this test are
-    //  instantiated in the same VM.  Being static (and using
-    //  static vars), it aint gonna work.  Not worrying about
-    //  it for now.
-    public static void main( String args[] ) throws InterruptedException
-    {
-        mainThread = Thread.currentThread();
-        try
-        {
-            init();
-        }
-        catch( TestPassedException e )
-        {
-            //The test passed, so just return from main and harness will
-            // interepret this return as a pass
-            return;
-        }
-        //At this point, neither test pass nor test fail has been
-        // called -- either would have thrown an exception and ended the
-        // test, so we know we have multiple threads.
-
-        //Test involves other threads, so sleep and wait for them to
-        // called pass() or fail()
-        try
-        {
-            Thread.sleep( sleepTime );
-            //Timed out, so fail the test
-            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+            throw new RuntimeException("TEST FAILED: " + thr);
         }
-        catch (InterruptedException e)
-        {
-            //The test harness may have interrupted the test.  If so, rethrow the exception
-            // so that the harness gets it and deals with it.
-            if( ! testGeneratedInterrupt ) throw e;
-
-            //reset flag in case hit this code more than once for some reason (just safety)
-            testGeneratedInterrupt = false;
-
-            if ( theTestPassed == false )
-            {
-                throw new RuntimeException( failureMessage );
-            }
-        }
-
-    }//main
-
-    public static synchronized void setTimeoutTo( int seconds )
-    {
-        sleepTime = seconds * 1000;
     }
-
-    public static synchronized void pass()
-    {
-        Sysout.println( "The test passed." );
-        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
-        //first check if this is executing in main thread
-        if ( mainThread == Thread.currentThread() )
-        {
-            //Still in the main thread, so set the flag just for kicks,
-            // and throw a test passed exception which will be caught
-            // and end the test.
-            theTestPassed = true;
-            throw new TestPassedException();
-        }
-        theTestPassed = true;
-        testGeneratedInterrupt = true;
-        mainThread.interrupt();
-    }//pass()
-
-    public static synchronized void fail()
-    {
-        //test writer didn't specify why test failed, so give generic
-        fail( "it just plain failed! :-)" );
-    }
-
-    public static synchronized void fail( String whyFailed )
-    {
-        Sysout.println( "The test failed: " + whyFailed );
-        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
-        //check if this called from main thread
-        if ( mainThread == Thread.currentThread() )
-        {
-            //If main thread, fail now 'cause not sleeping
-            throw new RuntimeException( whyFailed );
-        }
-        theTestPassed = false;
-        testGeneratedInterrupt = true;
-        failureMessage = whyFailed;
-        mainThread.interrupt();
-    }//fail()
-
-}// class EmbeddedFrameTest1
-
-//This exception is used to exit from any level of call nesting
-// when it's determined that the test has passed, and immediately
-// end the test.
-class TestPassedException extends RuntimeException
-{
 }
-
-//*********** End Standard Test Machinery Section **********
-
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
-  chunk of code whose purpose is to make user
-  interaction uniform, and thereby make it simpler
-  to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
-  for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
-  WithInstructions method.  Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
-  with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
-  as standalone.
- */
-
-class Sysout
-{
-    private static TestDialog dialog;
-
-    public static void createDialogWithInstructions( String[] instructions )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        dialog.printInstructions( instructions );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-    public static void createDialog( )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        String[] defInstr = { "Instructions will appear here. ", "" } ;
-        dialog.printInstructions( defInstr );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-
-    public static void printInstructions( String[] instructions )
-    {
-        dialog.printInstructions( instructions );
-    }
-
-
-    public static void println( String messageIn )
-    {
-        dialog.displayMessage( messageIn );
-        System.out.println(messageIn);
-    }
-
-}// Sysout  class
-
-/**
-  This is part of the standard test machinery.  It provides a place for the
-   test instructions to be displayed, and a place for interactive messages
-   to the user to be displayed.
-  To have the test instructions displayed, see Sysout.
-  To have a message to the user be displayed, see Sysout.
-  Do not call anything in this dialog directly.
-  */
-class TestDialog extends Dialog
-{
-
-    TextArea instructionsText;
-    TextArea messageText;
-    int maxStringLength = 80;
-
-    //DO NOT call this directly, go through Sysout
-    public TestDialog( Frame frame, String name )
-    {
-        super( frame, name );
-        int scrollBoth = TextArea.SCROLLBARS_BOTH;
-        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
-        add( "North", instructionsText );
-
-        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
-        add("Center", messageText);
-
-        pack();
-
-        setVisible(true);
-    }// TestDialog()
-
-    //DO NOT call this directly, go through Sysout
-    public void printInstructions( String[] instructions )
-    {
-        //Clear out any current instructions
-        instructionsText.setText( "" );
-
-        //Go down array of instruction strings
-
-        String printStr, remainingStr;
-        for( int i=0; i < instructions.length; i++ )
-        {
-            //chop up each into pieces maxSringLength long
-            remainingStr = instructions[ i ];
-            while( remainingStr.length() > 0 )
-            {
-                //if longer than max then chop off first max chars to print
-                if( remainingStr.length() >= maxStringLength )
-                {
-                    //Try to chop on a word boundary
-                    int posOfSpace = remainingStr.
-                        lastIndexOf( ' ', maxStringLength - 1 );
-
-                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
-                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
-                    remainingStr = remainingStr.substring( posOfSpace + 1 );
-                }
-                //else just print
-                else
-                {
-                    printStr = remainingStr;
-                    remainingStr = "";
-                }
-
-                instructionsText.append( printStr + "\n" );
-
-            }// while
-
-        }// for
-
-    }//printInstructions()
-
-    //DO NOT call this directly, go through Sysout
-    public void displayMessage( String messageIn )
-    {
-        messageText.append( messageIn + "\n" );
-        System.out.println(messageIn);
-    }
-
-}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/grab/MenuDragEvents/MenuDragEvents.html	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,44 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+  @test
+  @bug 6390326
+  @summary REGRESSION: Broken mouse behaviour of menus partially outside the main window.
+  @author oleg.sukhodolsky: area=awt-drab
+  @run applet MenuDragEvents.html
+  -->
+<head>
+<title>  </title>
+</head>
+<body>
+
+<h1>MenuDragEvents<br>Bug ID: 6390326 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="MenuDragEvents.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/grab/MenuDragEvents/MenuDragEvents.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,195 @@
+/*
+ * 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 6390326
+  @summary REGRESSION: Broken mouse behaviour of menus partially outside the main window.
+  @author oleg.sukhodolsky: area=awt-drab
+  @run applet AutomaticAppletTest.html
+*/
+
+/**
+ * MenuDragEvents.java
+ *
+ * summary: REGRESSION: Broken mouse behaviour of menus partially outside the main window.
+ */
+
+import java.applet.Applet;
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.AWTEventListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.WindowConstants;
+
+import javax.swing.event.MenuDragMouseEvent;
+import javax.swing.event.MenuDragMouseListener;
+
+public class MenuDragEvents extends Applet
+{
+    //Declare things used in the test, like buttons and labels here
+    boolean mouseDragged = false;
+    boolean mouseEntered = false;
+    boolean mouseReleased = false;
+    boolean actionReceived = false;
+
+    public void init()
+    {
+        // Set up the environment -- set the layout manager, add
+        // buttons, etc.
+
+        setLayout (new BorderLayout ());
+
+    }//End  init()
+
+    public void start ()
+    {
+        //Get things going.  Request focus, set size, et cetera
+        setSize (200,200);
+        setVisible(true);
+        validate();
+
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+                public void eventDispatched(AWTEvent event) {
+                    int id = event.getID();
+                    if (id == MouseEvent.MOUSE_ENTERED || id == MouseEvent.MOUSE_EXITED) {
+                        System.err.println(event);
+                    }
+                }
+            }, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
+        JMenuBar mb = new JMenuBar();
+
+        JMenu m = new JMenu("A Menu");
+        mb.add(m);
+
+        JMenuItem i = new JMenuItem("A menu item",KeyEvent.VK_A);
+        m.add(i);
+
+        m = new JMenu("Another Menu");
+        mb.add(m);
+        i = new JMenuItem("Yet another menu item",KeyEvent.VK_Y);
+        m.add(i);
+        i.addMenuDragMouseListener(new MenuDragMouseListener() {
+                public void menuDragMouseDragged(MenuDragMouseEvent e) {
+                    System.err.println(e);
+                    mouseDragged = true;
+                }
+                public void menuDragMouseEntered(MenuDragMouseEvent e) {
+                    System.err.println(e);
+                    mouseEntered = true;
+                }
+                public void menuDragMouseReleased(MenuDragMouseEvent e) {
+                    System.err.println(e);
+                    mouseReleased = true;
+                }
+                // perhaps we need to test mouse exited too
+                // but this doesn't work even with tiger
+                public void menuDragMouseExited(MenuDragMouseEvent e) {
+                    System.err.println(e);
+                }
+            });
+
+        i.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent ae) {
+                    System.err.println(ae);
+                    actionReceived = true;
+                }
+            });
+
+        JFrame frame = new JFrame("Menu");
+        frame.setJMenuBar(mb);
+        frame.setSize(200, 200);
+        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        frame.setVisible(true);
+
+        Robot r = null;
+        try {
+            r = new Robot();
+            r.setAutoDelay(50);
+        }
+        catch (AWTException ae) {
+            throw new RuntimeException(ae);
+        }
+
+        r.waitForIdle();
+
+        Point loc = m.getLocationOnScreen();
+        loc.x += m.getWidth() / 2;
+        loc.y += m.getHeight() / 2;
+        r.mouseMove(loc.x, loc.y);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+
+        r.waitForIdle();
+        r.delay(1000);
+
+        Point loc2 = i.getLocationOnScreen();
+        loc2.x += i.getWidth() / 2;
+        loc2.y += i.getHeight() / 2;
+
+        // move from menu on menubar to menu item
+        dragMouse(r, loc, loc2);
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+        r.waitForIdle();
+        r.delay(1000);
+
+        if (!mouseEntered || !mouseDragged || !mouseReleased || !actionReceived) {
+            throw new RuntimeException("we expected to receive both mouseEntered and MouseDragged ("
+                                       + mouseEntered + ", " + mouseDragged + ", " + mouseReleased
+                                       + ", " + actionReceived + ")");
+        }
+
+        System.out.println("Test passed");
+    }// start()
+
+    void dragMouse(Robot r, Point from, Point to) {
+        final int n_step = 10;
+        int step_x = (to.x - from.x) / n_step;
+        int step_y = (to.y - from.y) / n_step;
+        int x = from.x;
+        int y = from.y;
+        for (int idx = 0; idx < n_step; idx++) {
+            x += step_x;
+            y += step_y;
+            r.mouseMove(x, y);
+            r.delay(10);
+        }
+        if (x != to.x || y != to.y) {
+            r.mouseMove(to.x, to.y);
+            r.delay(10);
+        }
+    }
+
+}// class MenuDragEvents
--- a/jdk/test/java/awt/regtesthelpers/Util.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/java/awt/regtesthelpers/Util.java	Fri Dec 05 14:55:08 2014 +0300
@@ -63,8 +63,6 @@
 import java.awt.event.FocusListener;
 import java.awt.event.ActionListener;
 
-import java.awt.peer.FramePeer;
-
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
@@ -89,40 +87,6 @@
         }
     }
 
-    public static Frame createEmbeddedFrame(final Frame embedder)
-        throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
-               InstantiationException, InvocationTargetException
-    {
-        Toolkit tk = Toolkit.getDefaultToolkit();
-        FramePeer frame_peer = (FramePeer) embedder.getPeer();
-        System.out.println("frame's peer = " + frame_peer);
-        if ("sun.awt.windows.WToolkit".equals(tk.getClass().getName())) {
-            Class comp_peer_class =
-                Class.forName("sun.awt.windows.WComponentPeer");
-            System.out.println("comp peer class = " + comp_peer_class);
-            Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
-            hwnd_field.setAccessible(true);
-            System.out.println("hwnd_field =" + hwnd_field);
-            long hwnd = hwnd_field.getLong(frame_peer);
-            System.out.println("hwnd = " + hwnd);
-
-            Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
-            Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE});
-            return (Frame) constructor.newInstance (new Object[] {hwnd});
-        } else if ("sun.awt.X11.XToolkit".equals(tk.getClass().getName())) {
-            Class x_base_window_class = Class.forName("sun.awt.X11.XBaseWindow");
-            System.out.println("x_base_window_class = " + x_base_window_class);
-            Method get_window = x_base_window_class.getMethod("getWindow", new Class[0]);
-            System.out.println("get_window = " + get_window);
-            long window = (Long) get_window.invoke(frame_peer, new Object[0]);
-            System.out.println("window = " + window);
-            Class clazz = Class.forName("sun.awt.X11.XEmbeddedFrame");
-            Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE, Boolean.TYPE});
-            return (Frame) constructor.newInstance (new Object[] {window, true});
-        }
-
-        throw new RuntimeException("Unexpected toolkit - " + tk);
-    }
 
     /**
      * Makes the window visible and waits until it's shown.
@@ -237,8 +201,7 @@
     }
 
     public static void waitForIdle(final Robot robot) {
-        // we do not use robot for now, use SunToolkit.realSync() instead
-        ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        robot.waitForIdle();
     }
 
     public static Field getField(final Class klass, final String fieldName) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/regtesthelpers/UtilInternal.java	Fri Dec 05 14:55:08 2014 +0300
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package test.java.awt.regtesthelpers;
+
+import java.awt.peer.FramePeer;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.awt.Toolkit;
+import java.awt.Frame;
+
+
+
+/**
+   Class with static methods using internal/proprietary API by necessity.
+*/
+public final class UtilInternal {
+
+    private UtilInternal () {} // this is a helper class with static methods :)
+
+    public static Frame createEmbeddedFrame(final Frame embedder)
+        throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
+               InstantiationException, InvocationTargetException
+    {
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        FramePeer frame_peer = (FramePeer) embedder.getPeer();
+        System.out.println("frame's peer = " + frame_peer);
+        if ("sun.awt.windows.WToolkit".equals(tk.getClass().getName())) {
+            Class comp_peer_class =
+                Class.forName("sun.awt.windows.WComponentPeer");
+            System.out.println("comp peer class = " + comp_peer_class);
+            Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
+            hwnd_field.setAccessible(true);
+            System.out.println("hwnd_field =" + hwnd_field);
+            long hwnd = hwnd_field.getLong(frame_peer);
+            System.out.println("hwnd = " + hwnd);
+
+            Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
+            Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE});
+            return (Frame) constructor.newInstance (new Object[] {hwnd});
+        } else if ("sun.awt.X11.XToolkit".equals(tk.getClass().getName())) {
+            Class x_base_window_class = Class.forName("sun.awt.X11.XBaseWindow");
+            System.out.println("x_base_window_class = " + x_base_window_class);
+            Method get_window = x_base_window_class.getMethod("getWindow", new Class[0]);
+            System.out.println("get_window = " + get_window);
+            long window = (Long) get_window.invoke(frame_peer, new Object[0]);
+            System.out.println("window = " + window);
+            Class clazz = Class.forName("sun.awt.X11.XEmbeddedFrame");
+            Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE, Boolean.TYPE});
+            return (Frame) constructor.newInstance (new Object[] {window, true});
+        }
+
+        throw new RuntimeException("Unexpected toolkit - " + tk);
+    }
+}
--- a/jdk/test/javax/swing/JLabel/6596966/bug6596966.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/javax/swing/JLabel/6596966/bug6596966.java	Fri Dec 05 14:55:08 2014 +0300
@@ -25,16 +25,19 @@
    @bug 6596966
    @summary Some JFileChooser mnemonics do not work with sticky keys
    @library ../../regtesthelpers
-   @build Util
+   @library ../../../../lib/testlibrary
+   @build Util jdk.testlibrary.OSInfo
    @run main bug6596966
    @author Pavel Porvatov
 */
 
 import java.awt.*;
 import java.awt.event.KeyEvent;
+import java.awt.event.InputEvent;
 import java.util.ArrayList;
 import javax.swing.*;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
 
 public class bug6596966 {
     private static JFrame frame;
@@ -45,7 +48,6 @@
 
     public static void main(String[] args) throws Exception {
         Robot robot = new Robot();
-        SunToolkit toolkit = (SunToolkit) SunToolkit.getDefaultToolkit();
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -70,20 +72,25 @@
             }
         });
 
-        toolkit.realSync();
+        robot.waitForIdle();
+
 
-        ArrayList<Integer> keys = Util.getSystemMnemonicKeyCodes();
+        int keyMask = InputEvent.ALT_MASK;
+        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+            keyMask = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
+        }
+        ArrayList<Integer> keys = Util.getKeyCodesFromKeyMask(keyMask);
         for (int i = 0; i < keys.size(); ++i) {
             robot.keyPress(keys.get(i));
         }
 
         robot.keyPress(KeyEvent.VK_L);
 
-        toolkit.realSync();
-        toolkit.getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
+        robot.waitForIdle();
+        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
                 EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
 
-        toolkit.realSync();
+        robot.waitForIdle();
 
         try {
             SwingUtilities.invokeAndWait(new Runnable() {
@@ -98,7 +105,7 @@
             for (int i = 0; i < keys.size(); ++i) {
                 robot.keyRelease(keys.get(i));
             }
-            toolkit.realSync();
+            robot.waitForIdle();
         }
     }
 }
--- a/jdk/test/javax/swing/regtesthelpers/Util.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java	Fri Dec 05 14:55:08 2014 +0300
@@ -29,7 +29,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.Callable;
-import sun.swing.*;
+//import sun.swing.*;
 
 /**
  * <p>This class contains utilities useful for regression testing.
@@ -231,13 +231,6 @@
 
         return result.get(0);
     }
-    /**
-     * Gets key codes from system mnemonic key mask
-     * @return key codes list
-     */
-    public static ArrayList<Integer> getSystemMnemonicKeyCodes() {
-        return Util.getKeyCodesFromKeyMask(SwingUtilities2.getSystemMnemonicKeyMask());
-    }
 
     /**
      * Gets the key codes list from modifiers
--- a/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Fri Dec 05 12:41:29 2014 +0300
+++ b/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Fri Dec 05 14:55:08 2014 +0300
@@ -25,11 +25,10 @@
  * @bug 8024061
  * @summary Checks that no exception is thrown if dragGestureRecognized
  *          takes a while to complete.
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
+ * @run main bug8024061
  */
-import sun.awt.OSInfo;
-import sun.awt.OSInfo.OSType;
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.Transferable;
@@ -55,6 +54,8 @@
 import java.util.concurrent.TimeUnit;
 
 import javax.swing.*;
+import jdk.testlibrary.OSInfo;
+
 
 /**
  * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
@@ -106,8 +107,8 @@
     }
 
     public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
-        OSType type = OSInfo.getOSType();
-        if (type != OSType.LINUX && type != OSType.SOLARIS) {
+        OSInfo.OSType type = OSInfo.getOSType();
+        if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
             System.out.println("This test is for Linux and Solaris only... " +
                                "skipping!");
             return;
@@ -122,8 +123,7 @@
         });
         final Robot robot = new Robot();
         robot.setAutoDelay(10);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         JFrame frame = dnd[0].frame;
         Point point = frame.getLocationOnScreen();
@@ -138,7 +138,7 @@
             System.out.println("x = " + here.x);
         }
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         System.out.println("finished");