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