jdk/test/javax/swing/JTextArea/6940863/bug6940863.java
author yan
Thu, 18 Sep 2014 17:34:44 +0400
changeset 26750 d0d6c64a2e2b
parent 6661 f7cea28cc498
child 46151 5fa789776f7d
permissions -rw-r--r--
8058726: Update regtests using sun.awt.OSInfo, part 1 Reviewed-by: alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5592
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     1
/*
26750
d0d6c64a2e2b 8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents: 6661
diff changeset
     2
 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
5592
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     4
 *
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     8
 *
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    13
 * accompanied this code).
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    14
 *
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    18
 *
6374
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5592
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5592
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5592
diff changeset
    21
 * questions.
5592
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    22
 */
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    23
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    24
/* @test
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    25
 * @bug 6940863
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    26
 * @summary Textarea within scrollpane shows vertical scrollbar
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    27
 * @author Pavel Porvatov
26750
d0d6c64a2e2b 8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents: 6661
diff changeset
    28
 * @library ../../../../lib/testlibrary
d0d6c64a2e2b 8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents: 6661
diff changeset
    29
 * @build jdk.testlibrary.OSInfo
5592
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    30
 * @run main bug6940863
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    31
 */
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    32
26750
d0d6c64a2e2b 8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents: 6661
diff changeset
    33
import jdk.testlibrary.OSInfo;
5592
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    34
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    35
import javax.swing.*;
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    36
import java.awt.*;
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    37
import java.awt.event.ActionEvent;
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    38
import java.awt.event.ActionListener;
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    39
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    40
public class bug6940863 {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    41
    private static JFrame frame;
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    42
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    43
    private static JScrollPane scrollPane;
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    44
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    45
    private static final Timer timer = new Timer(1000, new ActionListener() {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    46
        public void actionPerformed(ActionEvent e) {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    47
            boolean failed = scrollPane.getVerticalScrollBar().isShowing() ||
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    48
                    scrollPane.getHorizontalScrollBar().isShowing();
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    49
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    50
            frame.dispose();
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    51
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    52
            if (failed) {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    53
                throw new RuntimeException("The test failed");
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    54
            }
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    55
        }
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    56
    });
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    57
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    58
    public static void main(String[] args) throws Exception {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    59
        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    60
            System.out.println("The test is suitable only for Windows OS. Skipped");
6661
f7cea28cc498 6982753: javax/swing/JTextArea/6940863/bug6940863.java should be modified
malenkov
parents: 6374
diff changeset
    61
            return;
5592
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    62
        }
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    63
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    64
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    65
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    66
        SwingUtilities.invokeAndWait(new Runnable() {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    67
            public void run() {
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    68
                JTextArea textArea = new JTextArea();
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    69
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    70
                textArea.setLineWrap(true);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    71
                textArea.setWrapStyleWord(true);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    72
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    73
                scrollPane = new JScrollPane(textArea);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    74
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    75
                scrollPane.setMinimumSize(new Dimension(200, 100));
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    76
                scrollPane.setPreferredSize(new Dimension(300, 150));
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    77
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    78
                frame = new JFrame("Vertical scrollbar shown without text");
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    79
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    80
                frame.setContentPane(scrollPane);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    81
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    82
                frame.pack();
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    83
                frame.setVisible(true);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    84
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    85
                timer.setRepeats(false);
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    86
                timer.start();
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    87
            }
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    88
        });
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    89
    }
fc99326b0953 6925473: REGRESSION: JOptionPane in dialog is full-screen height
rupashka
parents:
diff changeset
    90
}