Given task is to draw a smiley face in Java Applet.
Approach:
- Create three Ovals, one for the face, two for the eyes.
- Fill eyes oval with black color.
- 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.setColor(Color.BLACK); 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 Smiley.java > appletviewer Smiley.html
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- Draw a Polygon in Java Applet
- Draw a ellipse and a rectangle in Java Applet
- Draw a Chessboard in Java Applet
- Draw an Olympic Symbol in Java Applet
- Java Applet | Draw a line using drawLine() method
- Difference between a Java Application and a Java Applet
- Java Applet Basics
- Java Code for Moving Text | Applet | Thread
- Java Applet | Implementing Flood Fill algorithm
- Java Applet | Digital Stopwatch
- Java Applet | How to display a Digital Clock
- Java Applet | How to display an Analog Clock
- How to draw a Clock using StillClock in Java
- How to draw Inscribed circle of a triangle using p5.js ?
- How to draw Horizontal and Vertical lines in an Android App using XML
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.Lang.Float class in Java
- Java.io.BufferedInputStream class in Java
- Java.io.ObjectInputStream Class in Java | Set 1
- Java.util.BitSet class in Java with Examples | Set 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

