Java AWT Color predefined color constant value
import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; class DrawPanel extends JPanel { public void paintComponent(Graphics g) { g.setColor(Color.red);// w ww .j a v a 2 s.c o m g.drawOval(10, 10, 50, 50); g.fillOval(70, 90, 140, 100); g.setColor(Color.blue); g.drawOval(190, 10, 90, 30); g.drawRect(10, 10, 60, 50); g.setColor(Color.cyan); g.fillRect(100, 10, 60, 50); g.drawRoundRect(190, 10, 60, 50, 15, 15); } } public class Main { public static void main(String[] args) { DrawPanel panel = new DrawPanel(); JFrame application = new JFrame(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); application.add(panel); application.setSize(250, 250); application.setVisible(true); } }