java JTextArea 中的自动结束行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4019981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
auto end line in JTextArea
提问by Nabo
I have a jTextArea with a long string.
Let's usume:
我有一个带有长字符串的 jTextArea。
让我们假设:
String str = "this is a toooo long string";
Now i want to show this string in one swing jTextArea. But my textArea has limited size on the frame. So, i'm not be able to see the entire string.
For exemple, the text area only shows:
"this is a t"
现在我想在一个摆动 jTextArea 中显示这个字符串。但是我的 textArea 在框架上的大小有限。所以,我无法看到整个字符串。
例如,文本区域只显示:
“这是一个 t”
It is possible to textarea avoid hidden characters auto introducing '\n'? Note: I don't want auto scrool.
textarea可以避免隐藏字符自动引入'\n'吗?注意:我不想要自动滚动。
Thanks
谢谢
回答by Syntax
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);
Taken from: http://download.oracle.com/javase/tutorial/uiswing/components/textarea.html
取自:http: //download.oracle.com/javase/tutorial/uiswing/components/textarea.html