Colored Hello World - Java 2D Graphics

Java examples for 2D Graphics:Text

Introduction

Using Colors

Syntax

Color(int R, int G, int B)
Color(int rgb)
Color(float r, float g, float b)

Color Constants

black, blue, cyan, darkGray, gray, green, ligntGray,
    magenta, orange, pink, red, white, yellow
                     

Demo Code

 
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
 
public class Main {
       //from   w  w w.  j  ava2  s .co m
        public void paint(Graphics g){
                g.setColor(Color.blue);
                g.drawString("Hello World...",30,180);
        }
}

Related Tutorials