Applet to make a smiley face

In this applet, we’ll be making a face using different shapes. The applet package contains methods to draw an Oval, a line, rectangle, rounded rectangle, arc, etc.
To make a smiley face, we will be using Ovals and arcs.
Syntax for drawing an Oval:

In the above syntax, drawOval() method needs to be supplied four arguments. The first two arguments to set the position of the oval along the x axis and the y axis and the last two arguments to set the width and height of the oval.
Syntax for drawing an Arc:

The drawArc() method needs to be accessed using an object with the dot operator. It needs to be supplied six arguments. The first two arguments to set the position of the arc along the x axis and the y axis and the next two to set the width and height of the arc respectively. The last two arguments determine the starting angle of the arc and angle of the arc.

Difference between drawOval() and fillOval().

‘draw’ is used to draw the outline of the given shape whereas ‘fill’ will fill the shape with the color which is set in the color pallet. To understand the difference properly, please refer the program given below.

The above applet is tested in Eclipse.
The output of the above program:
Output

The following two tabs change content below.