• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic