Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Draw a Smiley in Java Applet

  • Difficulty Level : Easy
  • Last Updated : 15 Nov, 2018

Given task is to draw a smiley face in Java Applet.


  1. Create three Ovals, one for the face, two for the eyes.
  2. Fill eyes oval with black color.
  3. Create an arc for the smile in the face.

Below is the implementation of the above approach:

Applet Program:

// Java program to Draw a 
// Smiley using Java Applet
import java.applet.*;
import java.awt.*;
public class Smiley extends Applet {
    public void paint(Graphics g)
        // Oval for face outline
        g.drawOval(80, 70, 150, 150);
        // Ovals for eyes
        // with black color filled
        g.fillOval(120, 120, 15, 15);
        g.fillOval(170, 120, 15, 15);
        // Arc for the smile
        g.drawArc(130, 180, 50, 20, 180, 180);

Note: To run the applet in command line use the following commands

> javac
> appletviewer Smiley.html

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!