Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add text to a textArea instead of replacing it

How can I add text to a JTextArea instead of replacing all of it?

I know about setText(String) but other than that I'm a bit lost.

like image 594
vamp658 Avatar asked Aug 31 '12 13:08

vamp658


People also ask

How do I add text to TextArea?

To add text to a textarea, access the value property on the element and set it to its current value plus the text to be appended, e.g. textarea. value += 'Appended text' . The value property can be used to get and set the content of a textarea element.

How do I add a new line to a TextArea in Java?

When you want to create a new line or wrap in your TextArea you have to add \n (newline) after the text. TextArea t = new TextArea(); t.

What is the difference between text field and TextArea?

The main difference between JTextField and JTextArea in Java is that a JTextField allows entering a single line of text in a GUI application while the JTextArea allows entering multiple lines of text in a GUI application.


1 Answers

You can use the append method like this:

textArea.append(additionalText);
like image 187
DadViegas Avatar answered Oct 23 '22 22:10

DadViegas