/* * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.awt.*; import java.awt.Label; /* * @test * @summary Create and dispose the Dialog * @library ../../../lib/testlibrary * @build ExtendedRobot * @run main TaskDialog */ public class TaskDialog extends Task { Frame frame; Dialog dialog; Panel panel; Button button; Canvas canvas; Checkbox checkbox; Choice choice; Container container; Label label; List list; Scrollbar scrollbar; TextArea textarea; TextField textfield; public static void main (String[] args) throws Exception { new TaskDialog(GUIComponent.class, new ExtendedRobot()).runTask(); } TaskDialog(Class guiClass, ExtendedRobot robot) throws Exception { super(guiClass, robot); } public void task() throws Exception { for (int i = 0; i < 10; i++) { EventQueue.invokeAndWait(() -> { frame = new Frame(); dialog = new Dialog(frame, "DialogTest"); dialog.setBackground(Color.green); dialog.setSize(600, 270); panel = new Panel(); container = new Container(); container.setLayout(new FlowLayout()); button = new Button("Button"); canvas = new Canvas(); checkbox = new Checkbox("CheckBox"); choice = new Choice(); choice.add("Choice 1"); choice.add("Choice 2"); choice.add("Choice 3"); choice.add("Choice 4"); label = new Label("Label"); list = new List(2); list.add("list 1"); list.add("list 2"); list.add("list 3"); scrollbar = new Scrollbar(); textarea = new TextArea("TextArea", 3, 10); textfield = new TextField("TextField"); container.add(button); container.add(canvas); container.add(checkbox); container.add(choice); container.add(label); container.add(list); container.add(scrollbar); container.add(textarea); container.add(textfield); panel.add(container); dialog.add(panel); dialog.setVisible(true); }); robot.waitForIdle(1000); EventQueue.invokeAndWait(() -> { dialog.dispose(); frame.dispose(); }); robot.waitForIdle(1000); } } }