TestDispose.java revision 5346
0N/A/*
1472N/A * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * Portions Copyright (c) 2012 IBM Corporation
0N/A */
0N/A
0N/A/* @test
0N/A * @bug 7155298
0N/A * @run main/othervm/timeout=60 TestDispose
0N/A * @summary Editable TextArea blocks GUI application from exit.
0N/A * @author Sean Chou
0N/A */
0N/A
0N/Aimport java.awt.FlowLayout;
0N/Aimport java.awt.Frame;
0N/Aimport java.awt.TextArea;
0N/Aimport java.awt.Toolkit;
0N/Aimport java.lang.reflect.InvocationTargetException;
0N/A
0N/Aimport javax.swing.JFrame;
0N/Aimport javax.swing.SwingUtilities;
0N/A
0N/Aimport sun.awt.SunToolkit;
0N/A
0N/Apublic class TestDispose {
0N/A
0N/A public static Frame frame = null;
0N/A public static TextArea textArea = null;
0N/A public static volatile Process worker = null;
0N/A
0N/A public void testDispose() throws InvocationTargetException,
0N/A InterruptedException {
0N/A SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
0N/A
0N/A SwingUtilities.invokeAndWait(new Runnable() {
0N/A @Override
0N/A public void run() {
0N/A frame = new JFrame("Test");
0N/A
0N/A textArea = new TextArea("editable textArea");
0N/A textArea.setEditable(true);
0N/A // textArea.setEditable(false); // this testcase passes if textArea is non-editable
0N/A
0N/A frame.setLayout(new FlowLayout());
0N/A frame.add(textArea);
0N/A
0N/A frame.pack();
0N/A frame.setVisible(true);
0N/A }
0N/A });
0N/A toolkit.realSync();
0N/A
0N/A SwingUtilities.invokeAndWait(new Runnable() {
0N/A @Override
0N/A public void run() {
0N/A frame.dispose();
0N/A }
0N/A });
0N/A toolkit.realSync();
0N/A }
0N/A
0N/A public static void main(String[] args) throws Exception{
0N/A if(args.length == 0) {
0N/A Runtime.getRuntime().addShutdownHook(new Thread(){
0N/A public void run() {
0N/A worker.destroy();
0N/A }
331N/A });
331N/A
331N/A System.out.println(System.getProperty("java.home")+"/bin/java TestDispose workprocess");
331N/A worker = Runtime.getRuntime().exec(System.getProperty("java.home")+"/bin/java TestDispose workprocess");
331N/A worker.waitFor();
331N/A return;
331N/A }
331N/A
331N/A TestDispose app = new TestDispose();
331N/A app.testDispose();
331N/A }
331N/A
331N/A}
331N/A