test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.java
changeset 54231 e4813eded7cb
parent 50834 9cf279436b9d
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
    18  *
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
       
    23 
    23 /*
    24 /*
    24   test
    25   @test
    25   @bug       6391688
    26   @key headful
    26   @summary   Tests that next mnemonic KeyTyped is consumed for a modal dialog.
    27   @bug        6391688
    27   @author    anton.tarasov@sun.com: area=awt.focus
    28   @summary    Tests that next mnemonic KeyTyped is consumed for a modal dialog.
    28   @run       applet ConsumeForModalDialogTest.html
    29   @run        main ConsumeForModalDialogTest
    29 */
    30 */
    30 
    31 
    31 import javax.swing.*;
    32 import javax.swing.*;
    32 import java.awt.*;
    33 import java.awt.*;
    33 import java.awt.event.*;
    34 import java.awt.event.*;
    34 import java.applet.Applet;
       
    35 import java.util.concurrent.atomic.AtomicBoolean;
       
    36 import java.lang.reflect.InvocationTargetException;
       
    37 
    35 
    38 public class ConsumeForModalDialogTest extends Applet {
    36 public class ConsumeForModalDialogTest {
    39     Robot robot;
    37     Robot robot;
    40     JFrame frame = new JFrame("Test Frame");
    38     JFrame frame = new JFrame("Test Frame");
    41     JDialog dialog = new JDialog((Window)null, "Test Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
    39     JDialog dialog = new JDialog((Window)null, "Test Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
    42     JTextField text = new JTextField();
    40     JTextField text = new JTextField();
    43     static boolean passed = true;
    41     static boolean passed = true;
    53             robot = new Robot();
    51             robot = new Robot();
    54             robot.setAutoDelay(50);
    52             robot.setAutoDelay(50);
    55         } catch (AWTException e) {
    53         } catch (AWTException e) {
    56             throw new RuntimeException("Error: unable to create robot", e);
    54             throw new RuntimeException("Error: unable to create robot", e);
    57         }
    55         }
    58         // Create instructions for the user here, as well as set up
       
    59         // the environment -- set the layout manager, add buttons,
       
    60         // etc.
       
    61         this.setLayout (new BorderLayout ());
       
    62     }
    56     }
    63 
    57 
    64     public void start() {
    58     public void start() {
    65 
    59 
    66         text.addKeyListener(new KeyAdapter() {
    60         text.addKeyListener(new KeyAdapter() {
    91         dialog.setSize(100, 100);
    85         dialog.setSize(100, 100);
    92         dialog.add(text);
    86         dialog.add(text);
    93 
    87 
    94         frame.setJMenuBar(menuBar);
    88         frame.setJMenuBar(menuBar);
    95         frame.setSize(100, 100);
    89         frame.setSize(100, 100);
       
    90         frame.setLocationRelativeTo(null);
    96         frame.setVisible(true);
    91         frame.setVisible(true);
    97 
    92 
    98         robot.waitForIdle();
    93         robot.waitForIdle();
    99 
    94 
   100         if (!frame.isFocusOwner()) {
    95         if (!frame.isFocusOwner()) {