java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.java
Print this page
*** 7,21 ****
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
- import sun.awt.SunToolkit;
public class DisposeDialogNotActivateOwnerTest extends Applet {
Robot robot;
- SunToolkit toolkit;
Frame frame = new Frame("Owner Frame");
Dialog dialog = new Dialog(new Frame(), "Owned Dialog");
Button frameButton = new Button("button");
--- 7,19 ----
*** 39,81 ****
this.setLayout (new BorderLayout ());
Sysout.createDialogWithInstructions(new String[]
{"This is automatic test. Simply wait until it is done."
});
! frame.setBounds(800, 0, 200, 100);
frame.add(frameButton);
dialog.setBounds(800, 300, 200, 100);
}
public void start() {
- toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
frameButton.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
passed = true;
}
});
frame.setVisible(true);
! toolkit.realSync();
// 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);
! toolkit.realSync();
// make sure the dialog is focused
if (!dialog.isFocused()) {
throw new RuntimeException("Error: a dialog didn't get initial focus.");
}
dialog.dispose();
! toolkit.realSync();
if (passed) {
Sysout.println("Test passed.");
} else {
throw new RuntimeException("Test failed: a dialog activates invisible owner when disposed!");
--- 37,78 ----
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!");
*** 94,104 ****
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(20);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
! toolkit.realSync();
}
}
/****************************************************
Standard Test Machinery
--- 91,101 ----
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(20);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
! robot.waitForIdle();
}
}
/****************************************************
Standard Test Machinery