java/awt/Choice/UnfocusableCB_ERR/UnfocusableCB_ERR.java
Print this page
@@ -1,16 +1,37 @@
/*
+ * 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.*;
-import sun.awt.SunToolkit;
public class UnfocusableCB_ERR
{
static final int delay = 100;
static Frame frame = new Frame("Test Frame");
@@ -56,11 +77,12 @@
frame.setVisible(true);
frame.validate();
try {
robot = new Robot();
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
testSpacePress();
} catch (Throwable e) {
UnfocusableCB_ERR.fail("Test failed. Exception thrown: "+e);
}
if (failed.equals("")){
@@ -72,29 +94,29 @@
public static void testSpacePress(){
pt = choice1.getLocationOnScreen();
robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + choice1.getHeight()/2);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
//position mouse cursor over dropdown menu
robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + 2 * choice1.getHeight());
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
//move mouse outside Choice
robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y - choice1.getHeight());
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
}
/*****************************************************