This is a Java Program to Display Human Face using Applet
We have to write a program in Java such that it displays a human face using applet.
For displaying human face using applet, we can have the following set of input and output.
When the Applet is Executed :
When the applet is executed, it is expected that a human face is drawn.
1. Initially, set the background color of frame as white.
2. Create a color which is similar to the human skin color, and then draw and fill the outer boundary of the face.
3. Then set the color to black.
4. Draw and fill the left eye and the right eye.
5. Draw the right eyebrow and the left eyebrow.
6. Draw the nose.
7. Draw the smile.
Here is source code of the Java Program to draw a human face using applet. The program is successfully compiled and tested using javac compiler on Fedora 30. The program output is also shown below.
/*Java Program to Draw a Human Face using Applet*/
public class Human_Face extends Applet
//Initialize the applet
public void init()
//Draw the human face
public void paint(Graphics g)
//Change color to cream
Color clr=new Color(255,179,86);
//Draw and fill the face
//Change color to black
//Draw the left eye
//Draw the right eye
//Draw the Left Eyebrow
//Draw the Right Eyebrow
//Draw the Nose
//Draw the smile
<applet code = Human_Face.class width=500 height=500>
To execute the applet use the following commands:
>>>javac Human_Face.java >>>appletviewer Human_Face.java
1. The RGB value (255,179,86) gives a kind of human skin color. Create a color using this value.
2. To draw and fill the face and eyes use drawOval and fillOval respectively.
3. To draw the eyebrows and smile use drawArc.
4. To draw the nose use drawArc and drawLine.
Here’s the run time test cases for drawing human face using an applet.
Sanfoundry Global Education & Learning Series – Java Programs.