1 /*
   2  * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 import java.awt.*;
  25 import java.awt.Label;
  26 
  27 /*
  28  * @test
  29  * @summary Create and dispose the Frame
  30  * @author Aruna Samji
  31  * @library ../../../lib/testlibrary
  32  * @build ExtendedRobot
  33  * @run main TaskFrame
  34  */
  35 
  36 public class TaskFrame extends Task<GUIComponent> {
  37 
  38     public static void main (String[] args) throws Exception {
  39         new TaskFrame(new GUIComponent(), new ExtendedRobot()).runTask();
  40     }
  41 
  42     public TaskFrame(GUIComponent gui, ExtendedRobot robot) {
  43         super(gui, robot);
  44     }
  45 
  46     public void task() throws Exception {
  47         Frame[] frame = new Frame[1];
  48 
  49         for (int i = 0; i < 10; i++) {
  50             frame[0] = new Frame("FrameTest");
  51             frame[0].setBackground(Color.blue);
  52             frame[0].setSize(600, 270);
  53 
  54             Panel panel = new Panel();
  55 
  56             Container container = new Container();
  57             container.setLayout(new FlowLayout());
  58 
  59             Button button = new Button("Button");
  60             Canvas canvas = new Canvas();
  61             Checkbox checkbox = new Checkbox("CheckBox");
  62             Choice choice = new Choice();
  63             choice.add("Choice 1");
  64             choice.add("Choice 2");
  65             choice.add("Choice 3");
  66             choice.add("Choice 4");
  67 
  68             Label label = new Label("Label");
  69             List list = new List(2);
  70             list.add("list 1");
  71             list.add("list 2");
  72             list.add("list 3");
  73             Scrollbar scrollbar = new Scrollbar();
  74 
  75             TextArea textarea = new TextArea("TextArea", 3, 10);
  76             TextField textfield = new TextField("TextField");
  77 
  78             container.add(button);
  79             container.add(canvas);
  80             container.add(checkbox);
  81             container.add(choice);
  82             container.add(label);
  83             container.add(list);
  84             container.add(scrollbar);
  85             container.add(textarea);
  86             container.add(textfield);
  87 
  88             panel.add(container);
  89             frame[0].add(panel);
  90 
  91             frame[0].setVisible(true);
  92             robot.waitForIdle(1000);
  93             frame[0].dispose();
  94             robot.waitForIdle(1000);
  95         }
  96     }
  97 }