Ad

Tuesday, August 20, 2013

Drawing Face by using Java Applet

Drawing Face by using Java Applet

import java.awt.*;
import javax.swing.*;

public class Face extends JApplet
{
    public void paint(Graphics g)
    {
        g.drawOval(60, 40, 120, 150);    //Head
        g.drawOval(77, 75, 30, 20);        //Left Eye
        g.drawOval(130, 75, 30, 20);    //Right Eye

        g.setColor(Color.red);
        g.fillOval(88, 81, 10, 10);        //Pupil(Left)
        g.fillOval(141, 81, 10, 10);    //Pupil(Right)

        g.setColor(Color.pink);
        g.drawOval(105, 100, 30, 30);    //Nose
        g.fillArc(80, 125, 80, 40, 180, 180);    //Mouth
        g.drawOval(45, 92, 15, 30);                //Left ear
        g.drawOval(180, 92, 15, 30);            //Right ear

        g.setColor(Color.black);

        g.drawOval(250, 40, 120, 150);        //Head
        g.drawOval(267, 75, 30, 20);        //Left Eye
        g.drawOval(320, 75, 30, 20);        //Right Eye

        g.setColor(Color.red);
        g.fillOval(278, 81, 10, 10);        //Pupil(Left)
        g.fillOval(331, 81, 10, 10);        //Pupil(Right)

        g.setColor(Color.pink);
        g.drawOval(294, 100, 30, 30);            //Nose
        g.fillArc(270, 125, 80, 40, 180, 180);    //Mouth
        g.drawOval(235, 92, 15, 30);                //Left ear
        g.drawOval(370, 92, 15, 30);            //Right ear
    }
}

0 comments:

Post a Comment