Draw Smiley Face Java Nested Panels

1. Creating Smiley Face

This tutorial, "Draw Smiley Face Java Nested Panels", gives command over graphics to a novice. Fill ovals and arc are arranged in such way it looks smiley face. For beautification, a background color of pink (predefined color) is given.

Example on Smiley Face
import java.awt.*;
public class SmileyFace extends Frame
  public SmileyFace()
    setTitle("Smiley Face");
    setSize(300, 300);
  public void paint(Graphics g)
    g.fillOval(10,40,250,250);      // pinky round face
    g.setColor(Color.black);         // lines will be in black
    g.fillOval(75, 80, 32, 32);       // left eye
    g.fillOval(180, 80, 32, 32);     // right eye
    g.drawArc(100,110,110,110,180,180);    // mouth
  public static void main(String args[])
    new SmileyFace();

Just change the mouth arc as follows to see a sad face.


Leave a Comment

Your email address will not be published.