Draw Smiley with Graphics - Java 2D Graphics

Java examples for 2D Graphics:Shape

Description

Draw Smiley with Graphics

Demo Code

 
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JComponent;

public class Main extends JComponent {

  public void paint(Graphics g) {

    Font f = new Font("Helvetica", Font.BOLD, 20);
    g.setFont(f);//from   w w w.j  a  v  a  2 s.co m
    g.drawString("test", 50, 30);
    g.drawOval(60, 60, 200, 200);
    g.fillOval(90, 120, 50, 20);
    g.fillOval(190, 120, 50, 20);
    g.drawLine(165, 125, 165, 175);
    g.drawArc(110, 130, 95, 95, 0, -180);
  }
}

Related Tutorials