-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.3.0
-
x86
-
windows_98
Name: rmT116609 Date: 09/27/2000
java version "1.3.0"
JTextArea word wrapping in 1.3 is still non-optimal. Sentences are wrapped by
breaking words in two parts, rather than preserving words and breaking on
whitespace. In my example program, and on my Win98 box, the word fox is broken
by leaving the 'f' on the top line and putting the 'ox' on the second line.
Sensible word wrap would, presumably, preserve the word "fox" and break on the
whitespace preceding the word.
import javax.swing.*;
import java.awt.Dimension;
import java.awt.event.*;
public class wordWrap {
static JTextArea jtf;
static JFrame frame;
public static void main(String[] args) {
frame=new JFrame("Word Wrap");
Box box=Box.createHorizontalBox();
frame.setContentPane(box);
jtf=new JTextArea();
jtf.setLineWrap(true);
jtf.setPreferredSize(new Dimension(100, 35));
jtf.setMaximumSize(jtf.getPreferredSize());
jtf.setMinimumSize(jtf.getPreferredSize());
box.add(jtf);
jtf.setText("The quick brown fox jumped over the lazy dog!");
frame.pack();
frame.show();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
}
}
(Review ID: 110089)
======================================================================