-2

I have a text area called text_ref. I need to append text to it, not over write it. Similar to a log, where text is appended to the log, and never overwritten. How do I append text to it? I am currently using "setText".

text_ref.setText(nationality + "is the nationality...");
mKorbel
  • 109,525
  • 20
  • 134
  • 319
modarwish
  • 72
  • 1
  • 8
  • There is append() method available. – Aniket Thakur Dec 05 '13 at 11:10
  • 1
    -1 one look at the documentation would have given the answer. I can understand it's sometimes hard to find what you're looking for if the method's name is something cryptic but man, `append()` is the *first method* in the list. – JJJ Dec 05 '13 at 11:12

3 Answers3

4

Use append method

text_ref.append(nationality + "is the nationality...");
Masudul
  • 21,823
  • 5
  • 43
  • 58
2

Use append method passing the String literal, which need to be appended

  text_ref.setText(nationality + "is the nationality...");
  text_ref.append("I am just appending here to the current text");
Keerthivasan
  • 12,760
  • 2
  • 32
  • 53
0

To append text in JTextArea child object you have to use the append method of this object.

text_ref.append("some text to append");

or

nationality = "Polish";
text_ref.append(nationality);
spawny
  • 1
  • 1