test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java
Print this page
*** 32,62 ****
*/
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() {
--- 32,59 ----
*** 64,77 ****
System.out.println(e);
}
}, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
createAndShowWindow();
! toolkit.realSync();
createAndShowFrame();
! toolkit.realSync();
// click on Frame
clickOn(getClickPoint(frame));
if (!frame.isFocused()) {
--- 61,74 ----
System.out.println(e);
}
}, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
createAndShowWindow();
! robot.waitForIdle();
createAndShowFrame();
! robot.waitForIdle();
// click on Frame
clickOn(getClickPoint(frame));
if (!frame.isFocused()) {
*** 94,104 ****
// Test 2. Verifies that clicking on a component of unfocusable Window
// won't activate it.
window.setFocusableWindowState(false);
! toolkit.realSync();
clickOn(getClickPoint(label));
if (window.isFocused()) {
--- 91,101 ----
// Test 2. Verifies that clicking on a component of unfocusable Window
// won't activate it.
window.setFocusableWindowState(false);
! robot.waitForIdle();
clickOn(getClickPoint(label));
if (window.isFocused()) {
*** 134,148 ****
}
static void clickOn(Point point) {
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
! toolkit.realSync();
}
static Point getClickPoint(Component c) {
Point p = c.getLocationOnScreen();
Dimension d = c.getSize();
--- 131,146 ----
}
static void clickOn(Point point) {
robot.mouseMove(point.x, point.y);
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
! robot.waitForIdle();
}
static Point getClickPoint(Component c) {
Point p = c.getLocationOnScreen();
Dimension d = c.getSize();