Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

changing colors of a certain string

807603Nov 22 2007 — edited Nov 23 2007
well, now i was wondering if it is possible to change the color and font of a certain string.

like,
String str = "Test";
str.setColor(Color.RED);
str.setFont(new Font(str.getFont().getName(), Font.BOLD, 12);
because, when i looked up colors, you have to use the Graphics interface, and drawString("test) and such...

so the question is really, how can i add colors, to strings typed in a JTextArea. (deffirent colors, for deffirent strings, so not just JTextArea.setColor();)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2007
Added on Nov 22 2007
3 comments
1,161 views