test/jdk/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java
changeset 54231 e4813eded7cb
parent 50834 9cf279436b9d
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
    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 /*
    25   test
    25   @test
    26   @bug       6426132
    26   @key headful
    27   @summary   Modal blocked window shouldn't steal focus when shown, or brought to front.
    27   @bug        6426132
    28   @author    anton.tarasov@...: area=awt.focus
    28   @summary    Modal blocked window shouldn't steal focus when shown, or brought to front.
    29   @run       applet ModalBlockedStealsFocusTest.html
    29   @library    ../../regtesthelpers
       
    30   @build      Util
       
    31   @run        main ModalBlockedStealsFocusTest
    30 */
    32 */
    31 
    33 
    32 import java.awt.*;
    34 import java.awt.*;
    33 import java.awt.event.*;
    35 import java.awt.event.*;
    34 import java.applet.Applet;
       
    35 import java.util.concurrent.atomic.AtomicBoolean;
    36 import java.util.concurrent.atomic.AtomicBoolean;
    36 import java.lang.reflect.InvocationTargetException;
       
    37 import test.java.awt.regtesthelpers.Util;
    37 import test.java.awt.regtesthelpers.Util;
    38 
    38 
    39 public class ModalBlockedStealsFocusTest extends Applet {
    39 public class ModalBlockedStealsFocusTest {
    40     Frame frame = new Frame("Blocked Frame");
    40     Frame frame = new Frame("Blocked Frame");
    41     Dialog dialog = new Dialog(frame, "Modal Dialog", Dialog.ModalityType.TOOLKIT_MODAL);
    41     Dialog dialog = new Dialog(frame, "Modal Dialog", Dialog.ModalityType.TOOLKIT_MODAL);
    42     AtomicBoolean lostFocus = new AtomicBoolean(false);
    42     AtomicBoolean lostFocus = new AtomicBoolean(false);
    43 
    43 
    44     public static void main(String[] args) {
    44     public static void main(String[] args) {
    45         ModalBlockedStealsFocusTest app = new ModalBlockedStealsFocusTest();
    45         ModalBlockedStealsFocusTest app = new ModalBlockedStealsFocusTest();
    46         app.init();
       
    47         app.start();
    46         app.start();
    48     }
       
    49 
       
    50     public void init() {
       
    51         // Create instructions for the user here, as well as set up
       
    52         // the environment -- set the layout manager, add buttons,
       
    53         // etc.
       
    54         this.setLayout (new BorderLayout ());
       
    55     }
    47     }
    56 
    48 
    57     public void start() {
    49     public void start() {
    58         if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
    50         if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
    59             System.out.println("The test is not for MToolkit.");
    51             System.out.println("The test is not for MToolkit.");