Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Stickman program that generates a stickman figure
- // Renee Waggoner
- // July 26, 2019
- // Special Requirements: None
- package stickman;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import javax.swing.JFrame;
- public class Stickman extends JFrame {
- Stickman (String name)
- {
- // setting background
- super(name);
- setSize (500, 500);
- setVisible (true);
- setDefaultCloseOperation (EXIT_ON_CLOSE);
- }
- public void paint (Graphics g)
- {
- Dimension d = getSize ();
- g.setColor (Color.white); //white board
- g.fillRect (0, 0, d.width, d.height);
- g.setColor(Color. yellow);
- g.fillRect(200, 164, 60, 150); //body
- g.fillRect(222, 147, 15, 17); //neck
- g.fillOval (210, 110, 40, 40); //attaching face to body
- g.setColor (Color.black);
- g.fillRect (217, 100, 28, 14); // hat
- g.drawOval(210, 110, 40, 40); // line of the face
- g.fillOval(220, 125, 4, 3); // left eye
- g.fillOval(237, 125, 4, 3); // right eye
- // left to right, vertical
- g.drawLine(210, 314, 200, 380); // left leg
- g.drawLine(252, 314, 260, 380); // right leg
- g.drawLine (207, 112, 252, 112); // line of the hat
- g.drawLine(200, 172, 155, 180); // left arm
- g.drawLine(260, 172, 300, 180); // right arm
- g.setColor(Color.gray);
- g.drawLine(228, 132, 231, 132); // nose
- g.setColor(Color. yellow);
- g.fillRect(222, 147, 15, 17); //neck
- }
- public static void main(String[] args) {
- Stickman s = new Stickman ("My First Drawing");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement