< prev index next >

test/jdk/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.java

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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   @bug        5090325
  27   @summary    Tests that Window's child can be focused on XAWT.
  28   @author     anton.tarasov@sun.com: area=awt.focus
  29   @run        applet ChildWindowFocusTest.html
  30 */
  31 
  32 import java.awt.*;
  33 import java.awt.event.*;
  34 import java.applet.Applet;
  35 import java.lang.reflect.*;
  36 
  37 public class ChildWindowFocusTest extends Applet {
  38     Robot robot;
  39     Frame frame = new Frame("Owner");
  40     Button button0 = new Button("button-0");
  41     TextField text0 = new TextField("text-0");
  42     TextField text1 = new TextField("text-1");
  43     Window win1 = new TestWindow(frame, text0, 110);
  44     Window win2 = new TestWindow(win1, text1, 220);
  45     Frame outerFrame = new Frame("Outer");
  46     Button button1 = new Button("button-1");
  47     int shift;
  48 






  49     public void init() {
  50         try {
  51             robot = new Robot();
  52         } catch (AWTException e) {
  53             throw new RuntimeException("Error: unable to create robot", e);
  54         }
  55         // Create instructions for the user here, as well as set up
  56         // the environment -- set the layout manager, add buttons,
  57         // etc.
  58         this.setLayout (new BorderLayout ());
  59         shift = 100;
  60     }
  61 
  62     public void start() {
  63 
  64         frame.setBounds(0, 50, 400, 100);
  65         frame.setLayout(new FlowLayout());
  66         frame.add(button0);
  67 
  68         outerFrame.setBounds(0, 390, 400, 100);
  69         outerFrame.setLayout(new FlowLayout());
  70         outerFrame.add(button1);
  71 
  72         adjustAndShow(new Component[] {frame, win1, win2, outerFrame});
  73         robot.waitForIdle();
  74 
  75         test();
  76     }
  77 
  78     void adjustAndShow(Component[] comps) {




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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        5090325
  28   @summary    Tests that Window's child can be focused on XAWT.
  29   @run        main ChildWindowFocusTest

  30 */
  31 
  32 import java.awt.*;
  33 import java.awt.event.*;


  34 
  35 public class ChildWindowFocusTest {
  36     Robot robot;
  37     Frame frame = new Frame("Owner");
  38     Button button0 = new Button("button-0");
  39     TextField text0 = new TextField("text-0");
  40     TextField text1 = new TextField("text-1");
  41     Window win1 = new TestWindow(frame, text0, 110);
  42     Window win2 = new TestWindow(win1, text1, 220);
  43     Frame outerFrame = new Frame("Outer");
  44     Button button1 = new Button("button-1");
  45     int shift;
  46 
  47     public static void main(final String[] args) {
  48         ChildWindowFocusTest app = new ChildWindowFocusTest();
  49         app.init();
  50         app.start();
  51     }
  52 
  53     public void init() {
  54         try {
  55             robot = new Robot();
  56         } catch (AWTException e) {
  57             throw new RuntimeException("Error: unable to create robot", e);
  58         }




  59         shift = 100;
  60     }
  61 
  62     public void start() {
  63 
  64         frame.setBounds(0, 50, 400, 100);
  65         frame.setLayout(new FlowLayout());
  66         frame.add(button0);
  67 
  68         outerFrame.setBounds(0, 390, 400, 100);
  69         outerFrame.setLayout(new FlowLayout());
  70         outerFrame.add(button1);
  71 
  72         adjustAndShow(new Component[] {frame, win1, win2, outerFrame});
  73         robot.waitForIdle();
  74 
  75         test();
  76     }
  77 
  78     void adjustAndShow(Component[] comps) {


< prev index next >