如何在JTextArea中包装文本

时间:2022-11-29 11:05:16

I have a JTextArea in Java. When I place a large amount of text in it, the text area provides horizontal scrolling.

我在Java中有一个JTextArea。当我在其中放置大量文本时,文本区域提供水平滚动。

How can I make my text area wrap instead?

如何让我的文本区域换行?

4 个解决方案

#1


59  

Use the JTextArea#setLineWrap method. This is also illustrated in the Swing JTextArea tutorial

使用JTextArea #setLineWrap方法。这也在Swing JTextArea教程中说明

#2


23  

Look at the API for the methods available to JTextArea, in particular setWrapStyleWord and setLineWrap.

查看可用于JTextArea的方法的API,特别是setWrapStyleWord和setLineWrap。

#3


13  

Try This :

尝试这个 :

jTextArea.setLineWrap(true);

#4


1  

In a Swing GUI Designer Like Netbeans IDE,

在像Netbeans IDE一样的Swing GUI Designer中,

you could just 'check' the lineWrap in jTextArea property window.

你可以在jTextArea属性窗口中“检查”lineWrap。

if property window is hidden:

如果隐藏属性窗口:

Goto WINDOW -> IDE TOOLS -> Properties

or press

或按

CTRL + SHIFT + 7

In Swing GUI

在Swing GUI中

add the line

添加线

jTextArea.setLineWrap(true);

#1


59  

Use the JTextArea#setLineWrap method. This is also illustrated in the Swing JTextArea tutorial

使用JTextArea #setLineWrap方法。这也在Swing JTextArea教程中说明

#2


23  

Look at the API for the methods available to JTextArea, in particular setWrapStyleWord and setLineWrap.

查看可用于JTextArea的方法的API,特别是setWrapStyleWord和setLineWrap。

#3


13  

Try This :

尝试这个 :

jTextArea.setLineWrap(true);

#4


1  

In a Swing GUI Designer Like Netbeans IDE,

在像Netbeans IDE一样的Swing GUI Designer中,

you could just 'check' the lineWrap in jTextArea property window.

你可以在jTextArea属性窗口中“检查”lineWrap。

if property window is hidden:

如果隐藏属性窗口:

Goto WINDOW -> IDE TOOLS -> Properties

or press

或按

CTRL + SHIFT + 7

In Swing GUI

在Swing GUI中

add the line

添加线

jTextArea.setLineWrap(true);