test/jdk/java/awt/Focus/ShowFrameCheckForegroundTest/ShowFrameCheckForegroundTest.java
changeset 54231 e4813eded7cb
parent 50834 9cf279436b9d
child 55194 4cfbcfac47aa
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
    26   @key headful
    26   @key headful
    27   @bug       6492970
    27   @bug       6492970
    28   @summary   Tests that showing a toplvel in a not foreground Java process activates it.
    28   @summary   Tests that showing a toplvel in a not foreground Java process activates it.
    29   @library   ../../regtesthelpers
    29   @library   ../../regtesthelpers
    30   @build     Util
    30   @build     Util
    31   @author    Anton Tarasov: area=awt-focus
       
    32   @run       main ShowFrameCheckForegroundTest
    31   @run       main ShowFrameCheckForegroundTest
    33  */
    32  */
    34 
    33 
    35 import java.awt.*;
    34 import java.awt.*;
    36 import java.awt.event.*;
    35 import java.awt.event.*;
    37 import java.applet.Applet;
       
    38 import java.util.concurrent.atomic.AtomicBoolean;
       
    39 import java.lang.reflect.InvocationTargetException;
       
    40 import test.java.awt.regtesthelpers.Util;
    36 import test.java.awt.regtesthelpers.Util;
    41 
    37 
    42 public class ShowFrameCheckForegroundTest extends Applet {
    38 public class ShowFrameCheckForegroundTest {
    43     Robot robot;
    39     Robot robot;
    44     Frame nofocusFrame = new Frame("Non-focusable");
    40     Frame nofocusFrame = new Frame("Non-focusable");
    45     Frame frame = new Frame("Frame");
    41     Frame frame = new Frame("Frame");
    46     Dialog dialog1 = new Dialog(nofocusFrame, "Owned Dialog", false);
    42     Dialog dialog1 = new Dialog(nofocusFrame, "Owned Dialog", false);
    47     Dialog dialog2 = new Dialog((Frame)null, "Owned Dialog", false);
    43     Dialog dialog2 = new Dialog((Frame)null, "Owned Dialog", false);
    74             }
    70             }
    75         });
    71         });
    76         nofocusFrame.add(showButton);
    72         nofocusFrame.add(showButton);
    77         nofocusFrame.pack();
    73         nofocusFrame.pack();
    78         nofocusFrame.setFocusableWindowState(false);
    74         nofocusFrame.setFocusableWindowState(false);
       
    75         nofocusFrame.setLocation(200, 200);
    79         nofocusFrame.setVisible(true);
    76         nofocusFrame.setVisible(true);
    80         Util.waitForIdle(robot);
    77         Util.waitForIdle(robot);
    81 
    78 
    82         robot.delay(3000);
    79         robot.delay(3000);
    83 
    80 
    95     }
    92     }
    96 
    93 
    97     private void test(Window toplevel, int stage) {
    94     private void test(Window toplevel, int stage) {
    98         toplevel.add(testButton);
    95         toplevel.add(testButton);
    99         toplevel.pack();
    96         toplevel.pack();
   100         toplevel.setLocation(200, 0);
    97         toplevel.setLocation(400, 200);
   101 
    98 
   102         switch (stage) {
    99         switch (stage) {
   103             case 1:
   100             case 1:
   104                 toplevel.setVisible(true);
   101                 toplevel.setVisible(true);
   105                 break;
   102                 break;