Path: blob/master/test/jdk/javax/swing/JTextArea/Test6593649.java
41149 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/*24* @test25* @key headful26* @bug 659364927* @summary Word wrap does not work in JTextArea: long lines are not wrapped28* @author Lillian Angel29* @run main Test659364930*/3132import javax.swing.*;33import java.awt.*;34import java.awt.event.ActionEvent;35import java.awt.event.ActionListener;3637public class Test6593649 {38private static JFrame frame;3940private static JTextArea textArea;4142private static final Timer timer = new Timer(1000, new ActionListener() {43public void actionPerformed(ActionEvent e) {44boolean failed = !textArea.getParent().getSize().equals(textArea.getSize());4546frame.dispose();4748if (failed) {49throw new RuntimeException("The test failed");50}51}52});5354public static void main(String[] args) throws Exception {55SwingUtilities.invokeAndWait(new Runnable() {56public void run() {57frame = new JFrame();5859frame.setSize(200, 100);6061textArea = new JTextArea("This is a long line that should wrap, but doesn't...");6263textArea.setLineWrap(true);64textArea.setWrapStyleWord(true);6566JPanel innerPanel = new JPanel();6768innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.LINE_AXIS));69innerPanel.add(textArea);7071frame.getContentPane().add(innerPanel, BorderLayout.SOUTH);7273frame.setVisible(true);7475timer.setRepeats(false);76timer.start();77}78});79}80}818283