Set Graphics Color - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

Set Graphics Color

Demo Code


import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
 
public class Main {
        public void paint(Graphics g) {
                Color customColor = new Color(10,10,255);
               //w w w.j  a  va  2 s  .  c o m
                g.setColor(customColor);
                g.drawLine(10,10,30,30);
               
                g.setColor(Color.red);
                g.fillRect(40,40,40,40);
               
                g.setColor(Color.green);
                g.fillRect(80,80,40,40);
               
                g.draw3DRect(80,1,40,40,true);
        }
}

Related Tutorials