• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How do I have a multicolored text in JTextArea? (VERY URGENT )

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone pls help me in adding multicolored text in JTextArea, for example, 2 line of blue and then 4 in black and then again 2 lines in blue.
Please help me asap....!!
Anukampa.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
i found that this cannot be done in jdk 1.2 i dont know abt. 1.3
thanks

Originally posted by anukampa malhi:
Can anyone pls help me in adding multicolored text in JTextArea, for example, 2 line of blue and then 4 in black and then again 2 lines in blue.
Please help me asap....!!
Anukampa.


 
Anu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are correct that i shd u use JTextPane but i m not able to get how can i actually use it. I have spend almost 3 days to work thru JTextPane but of no use. Can u please help me in same.
Thanx
Anukampa
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some sample code about how to use JTextPane:
JTextPane textPane = new JTextPane(new DefaultStyleDocument());
SimpleAttributeSet s = new SimpleAttributeSet();
StyleConstants.setFontFamily(s, "Times New Roman");
StyleConstants.setFontSize(s, 16);
StyleConstants.setBold(s, true);
StyleConstants.setForeground(s, Color.red);
textPane.getDocument().insertString(0, "hi, I am here\n", s);
Hope this helps.

Originally posted by anukampa malhi:
you are correct that i shd u use JTextPane but i m not able to get how can i actually use it. I have spend almost 3 days to work thru JTextPane but of no use. Can u please help me in same.
Thanx
Anukampa


 
I didn't say it. I'm just telling you what this tiny ad said.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic