Add formatted text

70 views Asked by At

im stuck on a simple question, i want to display formatted text in a swing control and keep on adding new values into it, i don't want to use .setText(.getText + text) for personal reasons, (something like the append method for text area is what I am looking for) I've tried JEditorpane, Textpane but all of them do not have append method. Which swing control should I use?

1

There are 1 answers

3
Hovercraft Full Of Eels On BEST ANSWER

While JEditorPane has no append method, you can certainly add text to its Document via its insertString(...) method, and I suggest that you look into doing this.


Edit
You ask:

it worked it out but it seems it works like setText, all the previous data vanishes.. how do i keep the previous data ?

Are you correctly passing in the first parameter, the offset? This should be the length of the current Document.