Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTextArea/Test6593649.java
38838 views
/*1* Copyright (c) 2007, 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 659364925@summary Word wrap does not work in JTextArea: long lines are not wrapped26@author Lillian Angel27@run main Test659364928*/2930import javax.swing.*;31import java.awt.*;32import java.awt.event.ActionEvent;33import java.awt.event.ActionListener;3435public class Test6593649 {36private static JFrame frame;3738private static JTextArea textArea;3940private static final Timer timer = new Timer(1000, new ActionListener() {41public void actionPerformed(ActionEvent e) {42boolean failed = !textArea.getParent().getSize().equals(textArea.getSize());4344frame.dispose();4546if (failed) {47throw new RuntimeException("The test failed");48}49}50});5152public static void main(String[] args) throws Exception {53SwingUtilities.invokeAndWait(new Runnable() {54public void run() {55frame = new JFrame();5657frame.setSize(200, 100);5859textArea = new JTextArea("This is a long line that should wrap, but doesn't...");6061textArea.setLineWrap(true);62textArea.setWrapStyleWord(true);6364JPanel innerPanel = new JPanel();6566innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.LINE_AXIS));67innerPanel.add(textArea);6869frame.getContentPane().add(innerPanel, BorderLayout.SOUTH);7071frame.setVisible(true);7273timer.setRepeats(false);74timer.start();75}76});77}78}798081