SagittariusA
SagittariusA

Reputation: 5427

How to set columns in a JTextArea to show text

I'm using (in a JPanel with GridLayout) some JTextAreas (with Editable=false) to show some text after a query to a database XML.

JTextArea obj = new JTextArea();
obj.setColumns(37);
obj.setText(r.getProtocolloList().get(i).getOggetto());

The problem is that this text can be quite long and it is showed all in a single line so that the user has to scroll the horizontal JScrollPane to read the rest. I thought that setting the columns the line would be restricted so that the text would be showed in different lines. But nothing happens. Is there a way to get that? Thanks

Upvotes: 2

Views: 1919

Answers (1)

Zach
Zach

Reputation: 4792

Use the setLineWrap(); method:

obj.setLineWrap(true);

Upvotes: 1

Related Questions