JTextArea vs. JTextPane
843804Jun 27 2003 — edited Aug 25 2008Hi,
I am writing a simple chat where the content area is currently a JTextArea. The nice thing about JTextArea is it has an append(String) method to keep track of all the chat messages. The downside of it is it doesn't allow me to format the internal text message so you'll end up with the whole screen with the same colour.
The alternative is JTextPane where I can set its setContentType("text/html") where it gives me a bit of a freedom to format the output text. The downside of this is it doesn't append the text just reset - setText(String) - everything to the new message has been typed.
My question is, is there anything that'll allow me to have the flexibility of being able to append text strings to the current content area and yet allow me to format the text like JTextPane? In the worst scenario, I guess I can just extends JTextPane and add my own method but just wondering if there is a mechanism to accomplish this that I might not be aware of.
Regards,