문제

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?

도움이 되었습니까?

해결책

Use the append feature, like this

Text.append("button1,");

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top