How to display bold text in only parts of JTextArea?

No. What you're looking for is JEditorPane.

Up vote 0 down vote favorite share g+ share fb share tw.

This is an exploratory query. I am wondering if the following is possible with JTextArea? Can I alter the text to bold (append text) and then back to normal and will it only display the bold text in bold and the rest as normal?

Also can the contents of JTextArea be saved as a RTF document? Thank you. Java swing jtextarea link|improve this question edited Dec 15 '11 at 5:24pst38k43366 asked Apr 26 '10 at 13:40iGuygar87711542 97% accept rate.

I would use a JTextPane. It is easier to work with than trying to format and manipulate HTML. Click on the link to the Swing tutorial for a working example.

– camickr Apr 26 '10 at 15:34 thanks. Please contribute the link. :) – iGuygar Apr 26 '10 at 16:37.

No. What you're looking for is JEditorPane This supports HTML (3.2? ) which will allow you to use (and other older tags) to provide rich text.

JEditorPane textarea = new JEditorPane("text/html", ""); textarea. SetText("Here is some bold text"); EDIT: According to the javadoc I referenced above, JEditorPane also supports limited RTF. Don't forget to change the MIME to text/rtf.

– iGuygar Apr 26 '10 at 14:01 @ikurtz Yep, setText(getText() + "..."); – Matt Apr 26 '10 at 15:06 sorry but this does not work. As multiple tags are introduced so only the first occurance is displayed and rest of the data ignored. – iGuygar Apr 26 '10 at 20:01.

I believe you need a JTextPane or JEditorPane for that.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions