test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java
Print this page
@@ -32,31 +32,28 @@
*/
import java.awt.*;
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 {
private static Frame frame;
private static Window window;
private static Button fbutton;
private static Button wbutton;
private static Label label;
private static Robot robot;
- private static SunToolkit toolkit;
public static void main(String[] args) throws Exception {
if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("No testing on Motif. Test passed.");
return;
}
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@@ -64,14 +61,14 @@
System.out.println(e);
}
}, 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));
if (!frame.isFocused()) {
@@ -94,11 +91,11 @@
// Test 2. Verifies that clicking on a component of unfocusable Window
// won't activate it.
window.setFocusableWindowState(false);
- toolkit.realSync();
+ robot.waitForIdle();
clickOn(getClickPoint(label));
if (window.isFocused()) {
@@ -134,15 +131,16 @@
}
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) {
Point p = c.getLocationOnScreen();
Dimension d = c.getSize();