};
Sysout.createDialog( );
Sysout.printInstructions( instructions );
SunToolkit tk = (SunToolkit) Toolkit.getDefaultToolkit();
if ("sun.awt.motif.MToolkit".equals(tk.getClass().getName())) {
System.out.println("We shouldn't test MToolkit.");
EmbeddedFrameTest1.pass();
return;
}
try {
final Frame frame = new Frame("AWT Frame");
frame.pack();
frame.setSize(200,200);
final Frame embedded_frame = Util.createEmbeddedFrame(frame);
embedded_frame.setSize(200, 200);
Sysout.println("embedded_frame = " + embedded_frame);
final JPopupMenu menu = new JPopupMenu();
JButton item = new JButton("A button in popup");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Button pressed");
}
});
menu.add(item);
final JButton btn = new JButton("Press me to see popup");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
menu.show(btn, 0, btn.getHeight());
}
});
final Panel p = new Panel();
p.setLayout(new BorderLayout());
embedded_frame.add(p,BorderLayout.CENTER);
embedded_frame.validate();
p.add(btn);
p.validate();
frame.setVisible(true);
Robot robot = new Robot();
tk.realSync();
Util.clickOnComp(btn, robot);
tk.realSync();
Util.clickOnComp(item, robot);
tk.realSync();
if (item.getMousePosition() == null) {
throw new RuntimeException("Popup was not closed (mouse above it)");
}
embedded_frame.remove(p);
embedded_frame.dispose();