1 /*
2 * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
175 robot.keyRelease(KeyEvent.VK_SPACE);
176 waitForIdle();
177 try {
178 pressSema.doWait(3000);
179 } catch (InterruptedException ie) {
180 throw new RuntimeException("Interrupted!");
181 }
182 if (!pressSema.getState()) {
183 throw new RuntimeException("Type-ahead doesn't work");
184 }
185
186 }// start()
187
188 private void moveMouseOver(Container c) {
189 Point p = c.getLocationOnScreen();
190 Dimension d = c.getSize();
191 robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
192 }
193 private void waitForIdle() {
194 try {
195 Toolkit.getDefaultToolkit().sync();
196 sun.awt.SunToolkit.flushPendingEvents();
197 EventQueue.invokeAndWait( new Runnable() {
198 public void run() {
199 // dummy implementation
200 }
201 } );
202 } catch(InterruptedException ite) {
203 System.err.println("Robot.waitForIdle, non-fatal exception caught:");
204 ite.printStackTrace();
205 } catch(InvocationTargetException ine) {
206 System.err.println("Robot.waitForIdle, non-fatal exception caught:");
207 ine.printStackTrace();
208 }
209 }
210
211 private void waitTillShown(Component c) {
212 while (true) {
213 try {
214 Thread.sleep(100);
215 c.getLocationOnScreen();
216 break;
|
1 /*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
175 robot.keyRelease(KeyEvent.VK_SPACE);
176 waitForIdle();
177 try {
178 pressSema.doWait(3000);
179 } catch (InterruptedException ie) {
180 throw new RuntimeException("Interrupted!");
181 }
182 if (!pressSema.getState()) {
183 throw new RuntimeException("Type-ahead doesn't work");
184 }
185
186 }// start()
187
188 private void moveMouseOver(Container c) {
189 Point p = c.getLocationOnScreen();
190 Dimension d = c.getSize();
191 robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
192 }
193 private void waitForIdle() {
194 try {
195 robot.waitForIdle();
196 EventQueue.invokeAndWait( new Runnable() {
197 public void run() {
198 // dummy implementation
199 }
200 } );
201 } catch(InterruptedException ite) {
202 System.err.println("Robot.waitForIdle, non-fatal exception caught:");
203 ite.printStackTrace();
204 } catch(InvocationTargetException ine) {
205 System.err.println("Robot.waitForIdle, non-fatal exception caught:");
206 ine.printStackTrace();
207 }
208 }
209
210 private void waitTillShown(Component c) {
211 while (true) {
212 try {
213 Thread.sleep(100);
214 c.getLocationOnScreen();
215 break;
|