Program to draw Smiley in Applet

Program to draw Smiley in Applet

Topic : Total View : 108
This Java example shows how to draw smiley in an applet window using Java Applet class methods.

1. Create a Java file use this code below :

import java.applet.Applet;
import java.awt.*;
public class SmileyExc extends Applet {
 public void paint(Graphics g) {
  g.fillOval(20,20,150,150);   // For face
  g.fillOval(50,60,15,25);     // Left Eye 
  g.fillOval(120,60,15,25);    // Right Eye
  int x[] = {95,85,106,95};
  int y[] = {85,104,104,85};
  g.drawPolygon(x, y, 4);      // Nose
  g.drawArc(55,95,78,50,0,-180);  // Smile
  g.drawLine(50,126,60,116);   // Smile arc1
  g.drawLine(128,115,139,126);  // Smile arc2

2. Save it as ""

3. Run CMD

4. Compile with this code "javac"

5. Run with this code "appletviewer"

6. Done

Post By: Computer Program on Dec 20, 2018 07:25:06 Thursday IST

Note : If You want to create Your own New Topic, You can create here any topic for discuss with free mind. Share Your problems without obstacles for make Your mind light.