Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top