jdk/test/javax/swing/GroupLayout/8079640/bug8079640.java
author vromero
Thu, 05 Jan 2017 11:16:39 -0800
changeset 43033 c37b643739a7
parent 40128 e635645d2a8a
permissions -rw-r--r--
8148100: Convert lambda most specific positive tests to check runtime behavior Reviewed-by: mcimadamore Contributed-by: bsrbnd@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30950
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     1
/*
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     4
 *
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     8
 *
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    13
 * accompanied this code).
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    14
 *
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    18
 *
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    21
 * questions.
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    22
 */
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    23
40128
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    24
/*
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    25
 * @test
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    26
 * @key headful
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    27
 * @bug 8079640
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    28
 * @summary GroupLayout incorrect layout with large JTextArea
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    29
 * @author Semyon Sadetsky
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 30950
diff changeset
    30
 */
30950
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    31
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    32
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    33
import javax.swing.*;
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    34
import java.awt.*;
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    35
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    36
public class bug8079640 {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    37
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    38
    private static JFrame frame;
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    39
    private static JComponent comp2;
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    40
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    42
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    43
        try {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    44
            SwingUtilities.invokeAndWait(new Runnable() {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    45
                @Override
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    46
                public void run() {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    47
                    frame = new JFrame("A Frame");
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    48
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    49
                    frame.setUndecorated(true);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    50
                    setup(frame);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    51
                    frame.setVisible(true);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    52
                }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    53
            });
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    54
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    55
            test();
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    56
            System.out.println("ok");
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    57
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    58
        } finally {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    59
            SwingUtilities.invokeLater(new Runnable() {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    60
                @Override
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    61
                public void run() {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    62
                    frame.dispose();
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    63
                }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    64
            });
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    65
        }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    66
    }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    67
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    68
    private static void test() throws Exception {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    69
        SwingUtilities.invokeAndWait(new Runnable() {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    70
            @Override
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    71
            public void run() {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    72
                if(comp2.getLocation().getY() > frame.getHeight())
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    73
                    throw new RuntimeException("GroupLayout fails: comp2 is out of the window");
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    74
            }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    75
        });
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    76
    }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    77
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    78
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    79
    static void setup(JFrame frame)  {
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    80
        JPanel panel = new JPanel();
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    81
        JComponent comp1 = new JLabel("Test Label 1");
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    82
        comp1.setMinimumSize(new Dimension(1000, 40000));
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    83
        comp1.setPreferredSize(new Dimension(1000, 40000));
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    84
        JScrollPane scroll = new JScrollPane(comp1);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    85
        comp2 = new JLabel("Test Label 2");
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    86
        GroupLayout layout = new GroupLayout(panel);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    87
        layout.setHorizontalGroup(
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    88
                layout.createParallelGroup(GroupLayout.Alignment.LEADING)
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    89
                        .addComponent(scroll)
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    90
                        .addComponent(comp2));
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    91
        layout.setVerticalGroup(
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    92
                layout.createSequentialGroup()
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    93
                        .addComponent(scroll)
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    94
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    95
                        .addComponent(comp2));
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    96
        panel.setLayout(layout);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    97
        frame.getContentPane().add(panel, BorderLayout.CENTER);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    98
        frame.setSize(800, 600);
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
    99
    }
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
   100
2e6d6c55d109 8079640: GroupLayout incorrect layout with large JTextArea
ssadetsky
parents:
diff changeset
   101
}