86% found this document useful (7 votes)
11K views

Java Applet (Mickey Mouse)

This document contains the code for an applet that draws a cartoon face using various shapes and colors. It imports necessary libraries, declares colors and fonts, and contains a paint method that uses graphics methods like fillOval, fillArc, drawLine, etc. to draw the features of a face like eyes, nose, mouth, hair etc. using nested loops and arrays to define the polygon points.

Uploaded by

Jasper ﭢ Cazin
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
86% found this document useful (7 votes)
11K views

Java Applet (Mickey Mouse)

This document contains the code for an applet that draws a cartoon face using various shapes and colors. It imports necessary libraries, declares colors and fonts, and contains a paint method that uses graphics methods like fillOval, fillArc, drawLine, etc. to draw the features of a face like eyes, nose, mouth, hair etc. using nested loops and arrays to define the polygon points.

Uploaded by

Jasper ﭢ Cazin
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

import java.awt.

*;

import java.applet.*;

public class KHO extends Applet

{Font Font;

Color Bgcolor;

Color flesh;

Color orange;

Color pink;

public void init ()

{Font= new Font("Times", Font.ITALIC, 20);

flesh=new Color(255,218,185);

Bgcolor=(Color.pink);

orange=new Color(255,99,71);

pink=new Color(255,105,180);

setBackground(Bgcolor);

public void stop()

{}

public void paint (Graphics j)

j.setColor(Color.black);

j.fillOval(60,50,50,50);

j.fillOval(170,50,50,50);

j.fillOval(90,70,100,90);

j.setColor(flesh);
j.fillOval(110,80,60,80);

j.fillArc(90,70,100,90,180,180);

j.fillOval(90,110,30,8);

j.fillOval(160,110,30,8);

j.setColor(Color.black);

int x[]={130,150,140,130};

int y[]={80,80,90,80};

int n=4;

j.fillPolygon(x,y,n);

j.setColor(Color.white);

j.fillArc(120,95,18,40,0,180);

j.fillArc(140,95,18,40,0,180);

j.setColor(Color.black);

j.fillRoundRect(130,115,20,10,50,50);

j.fillOval(125,100,10,15);

j.fillOval(145,100,10,15);

j.drawArc(115,120,50,20,190,170);

j.drawArc(113,127,15,20,95,85);

j.drawArc(153,127,15,20,85,-85);

j.fillArc(130,130,30,20,180,200);

j.setColor(orange);

j.fillArc(138,145,15,10,10,165);

j.setColor(Color.black);

int x1[]={120,170,210,200,190,170,170,110,110,90,70,120};

int y1[]={160,160,220,230,220,190,220,220,210,210,190,160};
int n1=12;

j.fillPolygon(x1,y1,n1);

j.setColor(Color.white);

j.fillOval(70,210,50,40);

j.setColor(Color.red);

j.fillArc(38,190,133,60,0,90);

j.fillArc(98,180,40,80,135,135);

j.fillRect(118,220,52,39);

j.setColor(Color.white);

j.fillOval(160,220,50,40);

j.fillOval(110,200,20,20);

j.fillOval(130,200,20,20);

j.setColor(Color.black);

j.drawArc(130,218,20,40,180,88);

int x2[]={118,138,148,128,118};

int y2[]={259,259,295,290,259};

int n2=5;

j.fillPolygon(x2,y2,n2);

int x3[]={148,168,178,158,148};

int y3[]={259,259,290,295,259};

int n3=5;

j.fillPolygon(x3,y3,n3);

j.drawOval(80,290,90,40);

j.setColor(Color.yellow);
j.fillOval(80,290,90,40);

j.fillOval(140,290,80,40);

j.setColor(Color.black);

j.drawOval(140,290,80,40);

j.drawLine(170,240,180,230);

j.drawLine(170,250,185,235);

j.drawLine(180,250,190,240);

j.drawArc(150,258,40,40,0,90);

}}

You might also like