Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top