J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | * have any questions. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | @test |
| 26 | @bug 6547881 |
| 27 | @summary NPE when closing modal dialog |
| 28 | @author Oleg Sukhodolsky: area=awt.modal |
| 29 | @library ../../regtesthelpers |
| 30 | @build Util |
| 31 | @run main NpeOnCloseTest |
| 32 | */ |
| 33 | import java.awt.Dialog; |
| 34 | import java.awt.EventQueue; |
| 35 | import java.awt.Frame; |
| 36 | |
| 37 | import java.lang.reflect.InvocationTargetException; |
| 38 | |
| 39 | import test.java.awt.regtesthelpers.Util; |
| 40 | |
| 41 | public class NpeOnCloseTest { |
| 42 | public static void main(String[] args) |
| 43 | { |
| 44 | Frame frame1 = new Frame("frame 1"); |
| 45 | frame1.setBounds(0, 0, 100, 100); |
| 46 | frame1.setVisible(true); |
| 47 | Util.waitForIdle(null); |
| 48 | |
| 49 | Frame frame2 = new Frame("frame 2"); |
| 50 | frame2.setBounds(150, 0, 100, 100); |
| 51 | frame2.setVisible(true); |
| 52 | Util.waitForIdle(null); |
| 53 | |
| 54 | Frame frame3 = new Frame("frame 3"); |
| 55 | final Dialog dialog = new Dialog(frame3, "dialog", true); |
| 56 | dialog.setBounds(300, 0, 100, 100); |
| 57 | EventQueue.invokeLater(new Runnable() { |
| 58 | public void run() { |
| 59 | dialog.setVisible(true); |
| 60 | } |
| 61 | }); |
| 62 | try { |
| 63 | EventQueue.invokeAndWait(new Runnable() { public void run() {} }); |
| 64 | Util.waitForIdle(null); |
| 65 | EventQueue.invokeAndWait(new Runnable() { |
| 66 | public void run() { |
| 67 | dialog.dispose(); |
| 68 | } |
| 69 | }); |
| 70 | } |
| 71 | catch (InterruptedException ie) { |
| 72 | throw new RuntimeException(ie); |
| 73 | } |
| 74 | catch (InvocationTargetException ite) { |
| 75 | throw new RuntimeException(ite); |
| 76 | } |
| 77 | |
| 78 | frame1.dispose(); |
| 79 | frame2.dispose(); |
| 80 | frame3.dispose(); |
| 81 | } |
| 82 | } |