• Post Reply Bookmark Topic Watch Topic
  • New Topic

setting multiple values to textarea  RSS feed

 
Joe Don
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello forum, I am making use of NetBeans IDE 8.0 to build a GUI. The idea is that I set multiple values received from textfields to textarea. This will enable me print the work. But ONLY ONE value from textfields is set(appear on textarea); the others do not appear at all. Please, who knows the cause? What can I do to resolve this? Below is example of what I mean:
String s = jTextField1.getText();
JTextArea1.setText(s);
String x =
jTextField2.getText();
JTextArea1.setText(x);
NOTE: Only one is being set. The rest are not. It's annoying. Help!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"setText" replaces all existing text. If you want to append to it, try something like "ta.setText(ta.getText() + "\n" + x);"
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does JTextArea have an append() method? You can probably use that instead.
 
Anuj Sharma R
Greenhorn
Posts: 28
1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try append function.
Have a look here
Another could be insert function.
 
Joe Don
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, forum. It works for me really. I appreciate.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!