user3379721
user3379721

Reputation:

How to add text to JText area without deleting the previous text it has? java

I have a JText area in my program contain a text, and I want to add more text to it, when a button is pressed but without deleting the text that it already has on it. for example

JTextArea Text = new JTextArea("including; ");

When a button is pressed, I have to add another text but without deleting the one it has already, like so;

Text.setText("including button1");

and when another button is pressed it should look like this

Text.setText("including; button1, button2");

What is the most effective way of doing this?

Upvotes: 2

Views: 3610

Answers (1)

Seeker
Seeker

Reputation: 509

Use the append feature, like this

Text.append("button1,");

place this in the button / s and just write the name of the button

Upvotes: 2

Related Questions