test/jdk/javax/swing/JRootPane/MaximumSizeTest.java
author coleenp
Mon, 30 Sep 2019 13:10:11 -0400
changeset 58409 a595e67d6683
parent 47385 8d56044a9850
permissions -rw-r--r--
8184732: Deadlock detection improvements for 'special' locks Summary: Assert that special ranked locks cannot safepoint and allow_vm_block and remove locks from the exceptional lock list in no_safepoint_verifier. Reviewed-by: dholmes, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47385
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     1
/*
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     2
 * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     4
 *
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     8
 *
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    13
 * accompanied this code).
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    14
 *
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    18
 *
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    21
 * questions.
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    22
 */
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    23
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    24
/*
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    25
 * @test
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    26
 * @bug 6714836
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    27
 * @summary Tests if the maximum size of a JRootPane is appropriate.
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    28
 * @run main MaximumSizeTest
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    29
 */
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    30
import javax.swing.SwingUtilities;
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    31
import javax.swing.JRootPane;
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    32
import javax.swing.JLabel;
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    33
import java.awt.Dimension;
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    34
import java.lang.reflect.InvocationTargetException;
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    35
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    36
public class MaximumSizeTest {
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    37
    public static void main(String args[]) {
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    38
        try {
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    39
            SwingUtilities.invokeAndWait(() -> {
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    40
                JRootPane r = new JRootPane();
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    41
                r.getContentPane().add(new JLabel("foo"));
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    42
                System.out.println("Min Size: " + r.getMinimumSize());
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    43
                System.out.println("Preferred Size: " + r.getPreferredSize());
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    44
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    45
                Dimension d = r.getMaximumSize();
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    46
                if (d.width == 0 || d.height == 0) {
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    47
                    throw new RuntimeException("Maximum size is wrongly reported: " + d);
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    48
                }
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    49
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    50
                System.out.println("Max size: " + d);
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    51
            });
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    52
        } catch (InterruptedException | InvocationTargetException e) {
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    53
            System.out.println(e.getCause());
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    54
            throw new RuntimeException(e.getMessage());
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    55
        }
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    56
    }
8d56044a9850 6714836: JRootPane.getMaximumSize() returns a width of 0
aghaisas
parents:
diff changeset
    57
}