Smajl
Smajl

Reputation: 7995

JTextArea and long text format

This is probably very elementary question. I have a JTextArea, for example:

JTextArea area = new JTextArea();

I sometimes insert into this text area long pieces of text (for example using copy-paste method) - this area is for user input.

The problem is, that the text inserts only on one long line instead of adapting the the size of this component. Is there some easy way how to fix this?

Upvotes: 0

Views: 552

Answers (2)

Sanjaya Liyanage
Sanjaya Liyanage

Reputation: 4746

Hi there is a property to be set if you want this line wrapping.

JTextArea textArea = new JTextArea();
textArea.setLineWrap(true);

Hope this helps

Upvotes: 1

MadProgrammer
MadProgrammer

Reputation: 347184

Check out...

And you might find How to use Text Areas useful.

Upvotes: 6

Related Questions