简体   繁体   English

在JTextArea组件中自动创建新文本行

[英]Automatic Creation of new text lines in a JTextArea Component

I am using a jTextArea in a javaswing application with Netbeans 7. Want to make it possible to automatically create a new line when the text entered gets to the end of the jtextarea. 我正在NetBeans 7的javaswing应用程序中使用jTextArea。希望使输入的文本到达jtextarea的结尾时可以自动创建新行。 This will mean that there will not be a horizontal scrollbar. 这将意味着将没有水平滚动条。 The "enter" button will not need to be pressed before a new line is created 创建新行之前,无需按下“输入”按钮

A simple illustration is like when using a word document. 一个简单的插图就像使用Word文档时一样。 A new line is created when the user gets to the end of each line of the document. 当用户到达文档每一行的末尾时,将创建一个新行。

Any suggestion. 任何建议。

You can do this using 您可以使用

textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM