Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Creating colored text in Java

This is the code I have so far:

public class Hello extends GraphicsProgram {

public void run(){
  GLabel helloLabel = new GLabel("Programming is fun!");
  add(helloLabel, 100, 100);

}

How can I get "Programming is fun!" to appear in different colors and/or fonts?

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

If you are trying to run things on the command line, this'll help: http://stackoverflow.com/questions/5762491/how-to-print-color-in-console-using-system-out-println/5762502#5762502

If you are trying to do things in JavaFX, the GUI, I'd recommend taking the Build a JavaFX application course.

Let me know if that helps!

Thank you!! I'll give it a shot.

Craig Dennis
Craig Dennis
Treehouse Teacher

You got this! "Programming is fun!"