Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTextArea vs. JTextPane

843804Jun 27 2003 — edited Aug 25 2008
Hi,

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,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2008
Added on Jun 27 2003
7 comments
698 views