我有一个带长字符串的jTextArea.
我们来了:
String str = "this is a toooo long string";
Run Code Online (Sandbox Code Playgroud)
现在我想在一个swing jTextArea中显示这个字符串.但是我的textArea在框架上的尺寸有限.所以,我无法看到整个字符串.
例如,文本区域仅显示:
"这是一个t"
textarea可以避免隐藏字符自动引入'\n'?注意:我不想自动scrool.
谢谢
Syn*_*tax 21
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);
Run Code Online (Sandbox Code Playgroud)
摘自:http://download.oracle.com/javase/tutorial/uiswing/components/textarea.html