Login    New User    Forgot Password    Help      

Cartoon Applet

Java Tutorials

import java.awt.*;
import java.applet.*;

public class app6 extends Applet
{
public void paint(Graphics g)

{
//circle (Face)
g.drawOval(100,50,50,50);
g.setColor(new Color(239,236,185));
g.fillOval(100,51,50,50);

// eyes
g.setColor(Color.black);
g.fillOval(110,70,6,4);
g.fillOval(135,70,6,4);

// lips (arc)
g.drawArc(110,60,30,30,225,95);

 

//nose
int a[]={125,120,130};
int b[]={75,80,80};
int n=3;
g.setColor(Color.black);
g.drawPolygon(a,b,n);
g.setColor(Color.red);
g.fillPolygon(a,b,n);

//triangle (Cap)
int x[]={125,100,150};
int y[]={15,50,50};
int num=3;
g.drawPolygon(x,y,num);
g.setColor(Color.red);
g.fillPolygon(x,y,num);

//shirt
g.setColor(Color.cyan);
g.drawRect(75,100,100,100);
g.fillRect(75,100,100,100);

// pocket
g.setColor(Color.blue);
g.fillRect(145,122,15,20);
int x3[]={145,152,160};
int y3[]={122,128,122};
int num3=3;
g.drawPolygon(x3,y3,num3);
g.setColor(Color.red);
g.fillPolygon(x3,y3,num3);

 

// Arms
g.setColor(Color.cyan);
g.fillRect(25,100,50,20);
g.fillRect(175,100,50,20);

// Hands
g.setColor(Color.black);
g.drawOval(15,103,10,10);
g.drawOval(225,103,10,10);
g.setColor(new Color(239,236,185));
g.fillOval(15,103,10,10);
g.fillOval(225,103,10,10);

//buttons and bow
g.setColor(Color.blue);
g.fillRect(120,100,10,100);
g.setColor(Color.green);
g.fillOval(123,120,4,4);
g.fillOval(123,135,4,4);
g.fillOval(123,150,4,4);
g.fillOval(123,165,4,4);

// collers
int x1[]={105,120,120};
int y1[]={100,100,110};
int num1=3;
g.setColor(Color.red);
g.drawPolygon(x1,y1,num1);
g.fillPolygon(x1,y1,num1);

int x2[]={130,130,145};
int y2[]={100,110,100};
int num2=3;
g.drawPolygon(x2,y2,num2);
g.fillPolygon(x2,y2,num2);

 

// legs
g.setColor(Color.gray);
g.fillRect(85,200,30,100);
g.fillRect(135,200,30,100);

//shoes
g.setColor(Color.black);
g.fillRect(55,300,50,10);
g.fillRect(145,300,50,10);

}

}

Output

Output in applet

Java Tutorials