Applet program in java to draw a face

First, we do three things to make an applet program in java to draw a face

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

Also, you can use the Java compiler to compile a program.

Applet program in Java to draw a face

Implementation.

Import java.awt.*;
import java.applet.*;
 
public class smiley extends Applet
{
/* <applet code = "smiley" width = 300 height = 300> </applet> */	
	public void paint(Graphics g){
		
		Font f = new Font("Helvetica", Font.BOLD,20);
		g.setFont(f);
		g.drawString("Keep Smiling!!!", 50, 30);
		g.drawOval(60, 60, 200, 200);
		g.fillOval(90, 120, 50, 20);
		g.fillOval(190, 120, 50, 20);
		g.drawLine(165, 125, 165, 175);
		g.drawArc(110, 130, 95, 95, 0, -180);
	}
}

Output:

In the command line.

 C:\A>  smiley.java
 C:\A>  smiley.html

Also View: – Write a program to create a registration form using AWT.

Also View- Write a java program to create a window using swing.

About Ashishkumar Vishwakarma

I am Ashish- a Developer live in Mumbai.

View all posts by Ashishkumar Vishwakarma →

One Comment on “Applet program in java to draw a face”

  1. Good way of describing, and nice piece of writing to get data on the topic of my presentation subject, which i am going to deliver in college.|

Leave a Reply