我有一个包含长字符串的jTextArea。
假设:
String str = "this is a toooo long string";
现在我想在一个Swing jTextArea中显示这个字符串。但是我的文本区在框架上有限的大小。所以,我无法看到整个字符串。
例如,文本区仅显示:
"this is a t"
是否可能让文本区避免自动引入“\n”隐藏字符? 注:我不想要自动滚动。
谢谢
JTextArea textArea = new JTextArea(
"This is an editable JTextArea. " +
"A text area is a \"plain\" text component, " +
"which means that although it can display text " +
"in any font, all of the text is in the same font."
);
textArea.setFont(new Font("Serif", Font.ITALIC, 16));
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
参考自:http://download.oracle.com/javase/tutorial/uiswing/components/textarea.html