// -------------PersonApplet.java----------
import java.awt.*;
import java.applet.Applet;
public class PersonApplet extends Applet
{
public void paint(Graphics g)
{
// draw some people!
g.setColor(Color.red);
drawPerson(g, 50, 380, 200);
g.setColor(Color.cyan);
drawPerson(g, 100, 380, 200);
g.setColor(Color.blue);
drawPerson(g, 150, 380, 300);
}
private void drawPerson(Graphics g, int x, int y, int h)
{
// Draw head (about a 1/4 of the height in proportion)
g.fillOval(x-h/8, y-h, h/4, h/4);
// Draw body
g.drawLine(x, y-3*h/4, x, y - h/4);
// Draw legs
g.drawLine(x, y-h/4, x-h/8, y);
g.drawLine(x, y-h/4, x+h/8, y);
// Draw arms
g.drawLine(x, y-5*h/8, x-h/8, y-3*h/4);
g.drawLine(x, y-5*h/8, x+h/8, y-3*h/4);
}
}