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 command line.

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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *