< prev index next >

test/jdk/java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusToFrontTest.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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
  21  * questions.
  22  */
  23 
  24 /*
  25   @test
  26   @key headful
  27   @bug       6187066
  28   @summary   Tests the Window.autoRequestFocus property for the Window.toFront() method.
  29   @author    anton.tarasov: area=awt.focus
  30   @library /java/awt/patchlib     ../../regtesthelpers
  31   @build java.desktop/java.awt.Helper
  32   @build      Util
  33   @run       main AutoRequestFocusToFrontTest
  34 */
  35 
  36 import java.awt.*;
  37 import java.awt.event.*;
  38 import java.applet.Applet;
  39 import java.util.concurrent.atomic.AtomicBoolean;
  40 import java.lang.reflect.InvocationTargetException;
  41 import test.java.awt.regtesthelpers.Util;
  42 
  43 public class AutoRequestFocusToFrontTest extends Applet {
  44     static boolean haveDelays;
  45 
  46     static Frame auxFrame;
  47     static Frame frame;
  48     static Button frameButton;
  49     static Frame frame2;
  50     static Button frameButton2;
  51     static Frame frame3;
  52     static Button frameButton3;
  53     static Window window;
  54     static Button winButton;
  55     static Dialog dialog;
  56     static Button dlgButton;
  57     static Window ownedWindow;
  58     static Button ownWinButton;
  59     static Dialog ownedDialog;
  60     static Button ownDlgButton;
  61     static Dialog modalDialog;
  62     static Button modalDlgButton;
  63 
  64     static String toolkitClassName;
  65     static Robot robot = Util.createRobot();
  66 
  67     public static void main(String[] args) {
  68 
  69         if (args.length != 0) {
  70             haveDelays = "delay".equals(args[0]) ? true : false;
  71         }
  72 
  73         AutoRequestFocusToFrontTest app = new AutoRequestFocusToFrontTest();
  74         app.init();
  75         app.start();
  76     }
  77 
  78     public void init() {
  79         // Create instructions for the user here, as well as set up
  80         // the environment -- set the layout manager, add buttons,
  81         // etc.
  82         this.setLayout (new BorderLayout ());
  83         toolkitClassName = Toolkit.getDefaultToolkit().getClass().getName();
  84     }
  85 
  86     static void recreateGUI() {
  87         if (auxFrame != null) {
  88             auxFrame.dispose();
  89             frame.dispose();
  90             frame2.dispose();
  91             frame3.dispose();
  92             window.dispose();
  93             dialog.dispose();
  94             ownedWindow.dispose();
  95             ownedDialog.dispose();
  96             modalDialog.dispose();
  97         }
  98 
  99         auxFrame = new Frame("Auxiliary Frame");
 100 
 101         frame = new Frame("Test Frame");
 102         frameButton = new Button("button");




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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
  21  * questions.
  22  */
  23 
  24 /*
  25   @test
  26   @key headful
  27   @bug       6187066
  28   @summary   Tests the Window.autoRequestFocus property for the Window.toFront() method.

  29   @library /java/awt/patchlib     ../../regtesthelpers
  30   @build java.desktop/java.awt.Helper
  31   @build      Util
  32   @run       main AutoRequestFocusToFrontTest
  33 */
  34 
  35 import java.awt.*;




  36 import test.java.awt.regtesthelpers.Util;
  37 
  38 public class AutoRequestFocusToFrontTest {
  39     static boolean haveDelays;
  40 
  41     static Frame auxFrame;
  42     static Frame frame;
  43     static Button frameButton;
  44     static Frame frame2;
  45     static Button frameButton2;
  46     static Frame frame3;
  47     static Button frameButton3;
  48     static Window window;
  49     static Button winButton;
  50     static Dialog dialog;
  51     static Button dlgButton;
  52     static Window ownedWindow;
  53     static Button ownWinButton;
  54     static Dialog ownedDialog;
  55     static Button ownDlgButton;
  56     static Dialog modalDialog;
  57     static Button modalDlgButton;
  58 
  59     static String toolkitClassName;
  60     static Robot robot = Util.createRobot();
  61 
  62     public static void main(String[] args) {
  63 
  64         if (args.length != 0) {
  65             haveDelays = "delay".equals(args[0]) ? true : false;
  66         }
  67 
  68         AutoRequestFocusToFrontTest app = new AutoRequestFocusToFrontTest();
  69         app.init();
  70         app.start();
  71     }
  72 
  73     public void init() {




  74         toolkitClassName = Toolkit.getDefaultToolkit().getClass().getName();
  75     }
  76 
  77     static void recreateGUI() {
  78         if (auxFrame != null) {
  79             auxFrame.dispose();
  80             frame.dispose();
  81             frame2.dispose();
  82             frame3.dispose();
  83             window.dispose();
  84             dialog.dispose();
  85             ownedWindow.dispose();
  86             ownedDialog.dispose();
  87             modalDialog.dispose();
  88         }
  89 
  90         auxFrame = new Frame("Auxiliary Frame");
  91 
  92         frame = new Frame("Test Frame");
  93         frameButton = new Button("button");


< prev index next >