How can I change the color of the font or text?
I've tried area.setFontColor, area.setColor, comic.setColor.
area is the JTextArea.
comic is a font.
arial is a font.
I have a

final Color red = new Color();
red = Color.red;

but I don't know how to set the Font or Text to a Color. Do you know how?

Recommended Answers

All 7 Replies

You have create an instance of Font first and use that in your setFont() call.

Take a look at the tutorial on using JTextArea.

for text you can try

.setTextColor ([COLOR HERE]);

Awesome, thanks.

You have create an instance of Font first and use that in your setFont() call.

Take a look at the tutorial on using JTextArea.

The tutorial on your link doesn't tell me anything about the color of the font.

Try putting in this way.it works!

Font font = new Font("Verdana", Font.BOLD, 12);
txt.setFont(font);
txt.setForeground(Color.BLUE);

YAY! It works! :) :) :)
I wanna hug you!

Thank you SecOrg, make this thread as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.