Path: blob/master/test/jdk/javax/swing/JDialog/6639507/bug6639507.java
41153 views
/*1* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @key headful26* @bug 663950727* @summary Title of javax.swing.JDialog is null while spec says it's empty28* @author Pavel Porvatov29*/3031import javax.swing.*;32import java.awt.*;3334public class bug6639507 {35public static void main(String[] args) {36SwingUtilities.invokeLater(new Runnable() {37public void run() {38assertEmptyTitle(new Dialog((Frame) null), "new Dialog((Frame) null)");39assertEmptyTitle(new Dialog((Frame) null, true), "new Dialog((Frame) null, true)");40assertEmptyTitle(new Dialog((Dialog) null), "new Dialog((Dialog) null)");41assertEmptyTitle(new Dialog((Window) null), "new Dialog((Window) null)");42assertEmptyTitle(new Dialog(new Dialog((Window) null), Dialog.ModalityType.APPLICATION_MODAL),43"new Dialog((Window) null), Dialog.ModalityType.APPLICATION_MODAL");4445assertEmptyTitle(new JDialog((Frame) null), "new JDialog((Frame) null)");46assertEmptyTitle(new JDialog((Frame) null, true), "new JDialog((Frame) null, true)");47assertEmptyTitle(new JDialog((Dialog) null), "new JDialog((Dialog) null)");48assertEmptyTitle(new JDialog((Dialog) null, true), "new JDialog((Dialog) null, true)");49assertEmptyTitle(new JDialog((Window) null), "new JDialog((Window) null)");50assertEmptyTitle(new JDialog((Window) null, Dialog.ModalityType.APPLICATION_MODAL),51"new JDialog((Window) null, Dialog.ModalityType.APPLICATION_MODAL)");52}53});54}5556private static void assertEmptyTitle(Dialog dialog, String ctr) {57String title = dialog.getTitle();5859if (title == null || title.length() > 0) {60throw new RuntimeException("Title is not empty for constructor " + ctr);61}62}63}646566