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 Dialog 30 * @library ../../../lib/testlibrary 31 * @build ExtendedRobot 32 * @run main TaskDialog 33 */ 34 35 public class TaskDialog extends Task<GUIComponent> { 36 37 Frame frame; 38 Dialog dialog; 39 Panel panel; 40 Button button; 41 Canvas canvas; 42 Checkbox checkbox; 43 Choice choice; 44 Container container; 45 Label label; 46 List list; 47 Scrollbar scrollbar; 48 TextArea textarea; 49 TextField textfield; 50 51 public static void main (String[] args) throws Exception { 52 new TaskDialog(new GUIComponent(), new ExtendedRobot()).runTask(); 53 } 54 55 TaskDialog(GUIComponent gui, ExtendedRobot robot){ 56 super(gui, robot); 57 } 58 59 public void task() throws Exception { 60 for (int i = 0; i < 10; i++) { 61 frame = new Frame(); 62 dialog = new Dialog(frame, "DialogTest"); 63 dialog.setBackground(Color.green); 64 dialog.setSize(600, 270); 65 66 panel = new Panel(); 67 68 container = new Container(); 69 container.setLayout(new FlowLayout()); 70 71 button = new Button("Button"); 72 canvas = new Canvas(); 73 checkbox = new Checkbox("CheckBox"); 74 choice = new Choice(); 75 choice.add("Choice 1"); 76 choice.add("Choice 2"); 77 choice.add("Choice 3"); 78 choice.add("Choice 4"); 79 80 label = new Label("Label"); 81 list = new List(2); 82 list.add("list 1"); 83 list.add("list 2"); 84 list.add("list 3"); 85 scrollbar = new Scrollbar(); 86 87 textarea = new TextArea("TextArea", 3, 10); 88 textfield = new TextField("TextField"); 89 90 container.add(button); 91 container.add(canvas); 92 container.add(checkbox); 93 container.add(choice); 94 container.add(label); 95 container.add(list); 96 container.add(scrollbar); 97 container.add(textarea); 98 container.add(textfield); 99 100 panel.add(container); 101 dialog.add(panel); 102 103 dialog.setVisible(true); 104 robot.waitForIdle(1000); 105 106 dialog.dispose(); 107 frame.dispose(); 108 robot.waitForIdle(1000); 109 } 110 } 111 }