How to set color to specific word in JTextArea
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   zhang_yuezhong
Posted On:   Thursday, March 27, 2003 01:44 AM

I have:
JTextArea myText = new JTextArea("STOP! abcdefg hijklmn");

How do I highlight the word STOP in red, the rest is black. Thanks.

Re: How to set color to specific word in JTextArea

Posted By:   Bahman_Barzideh  
Posted On:   Thursday, March 27, 2003 05:01 AM

Can't be done. JTextArea is monochrome. It supports a
single foreground (text) color on a single background color. I also
supports a single Font for its text. for attributed text
support (different foreground/background colors, and different fonts
for different parts of the text), you should look into the JTextPane class or its parent class, JEditorPane.
You can find more information about text fields in this Sun tutorial on Using Text Components.
About | Sitemap | Contact