Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTextArea/6940863/bug6940863.java
38854 views
/*1* Copyright (c) 2010, 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/* @test24* @bug 694086325* @summary Textarea within scrollpane shows vertical scrollbar26* @author Pavel Porvatov27* @run main bug694086328*/2930import sun.awt.OSInfo;3132import javax.swing.*;33import java.awt.*;34import java.awt.event.ActionEvent;35import java.awt.event.ActionListener;3637public class bug6940863 {38private static JFrame frame;3940private static JScrollPane scrollPane;4142private static final Timer timer = new Timer(1000, new ActionListener() {43public void actionPerformed(ActionEvent e) {44boolean failed = scrollPane.getVerticalScrollBar().isShowing() ||45scrollPane.getHorizontalScrollBar().isShowing();4647frame.dispose();4849if (failed) {50throw new RuntimeException("The test failed");51}52}53});5455public static void main(String[] args) throws Exception {56if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {57System.out.println("The test is suitable only for Windows OS. Skipped");58return;59}6061UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");6263SwingUtilities.invokeAndWait(new Runnable() {64public void run() {65JTextArea textArea = new JTextArea();6667textArea.setLineWrap(true);68textArea.setWrapStyleWord(true);6970scrollPane = new JScrollPane(textArea);7172scrollPane.setMinimumSize(new Dimension(200, 100));73scrollPane.setPreferredSize(new Dimension(300, 150));7475frame = new JFrame("Vertical scrollbar shown without text");7677frame.setContentPane(scrollPane);78frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);79frame.pack();80frame.setVisible(true);8182timer.setRepeats(false);83timer.start();84}85});86}87}888990