• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set different color for the different text in a JTextArea  RSS feed

 
Chris Jebaraj
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.
Please help me out in this. I want to display some text (a part of the whole text) alone in Blue color in a JTextArea. Is there any way to do it. Is there any Renderer kind of things.
Thanks in Advance.
Jebaraj
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do this with a JTextArea. You will want to use a JEditorPane or JTextPane. Take a look at this.
 
Chris Jebaraj
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot... I tried using JTextPane with Styled Document, it works.. Now the problem is i have save the colored text alone in one format along with the whole text. Lets say "This is the <blue> example </blue> text" is my whole text, i want to save this as "This is the {example} text". Basically the blue colored text has to to formatted to {..} format. Would any one please help me out in this. i am struck up here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!