< prev index next >
test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.java
Print this page
*** 18,43 ****
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
! test
@bug 6391688
@summary Tests that next mnemonic KeyTyped is consumed for a modal dialog.
! @author anton.tarasov@sun.com: area=awt.focus
! @run applet ConsumeForModalDialogTest.html
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
- import java.applet.Applet;
- import java.util.concurrent.atomic.AtomicBoolean;
- import java.lang.reflect.InvocationTargetException;
! public class ConsumeForModalDialogTest extends Applet {
Robot robot;
JFrame frame = new JFrame("Test Frame");
JDialog dialog = new JDialog((Window)null, "Test Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
JTextField text = new JTextField();
static boolean passed = true;
--- 18,41 ----
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
/*
! @test
! @key headful
@bug 6391688
@summary Tests that next mnemonic KeyTyped is consumed for a modal dialog.
! @run main ConsumeForModalDialogTest
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
! public class ConsumeForModalDialogTest {
Robot robot;
JFrame frame = new JFrame("Test Frame");
JDialog dialog = new JDialog((Window)null, "Test Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
JTextField text = new JTextField();
static boolean passed = true;
*** 53,66 ****
robot = new Robot();
robot.setAutoDelay(50);
} catch (AWTException e) {
throw new RuntimeException("Error: unable to create robot", e);
}
- // Create instructions for the user here, as well as set up
- // the environment -- set the layout manager, add buttons,
- // etc.
- this.setLayout (new BorderLayout ());
}
public void start() {
text.addKeyListener(new KeyAdapter() {
--- 51,60 ----
*** 91,100 ****
--- 85,95 ----
dialog.setSize(100, 100);
dialog.add(text);
frame.setJMenuBar(menuBar);
frame.setSize(100, 100);
+ frame.setLocationRelativeTo(null);
frame.setVisible(true);
robot.waitForIdle();
if (!frame.isFocusOwner()) {
< prev index next >