Question

Im trying to create a program in java where I draw a stick figure, when you click on the stick figure it should get larger.   And you should be able to drag it.

Im trying to create a program in java where I draw a stick figure, when you click on the stick figure it should get larger.   And you should be able to drag it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import corejava.* ;//For closeableFrame

import java.awt.*;

public class StickFigure extends CloseableFrame{

            public void paint (Graphics g){

                   System.out.println("Stickcanvas.paint: with g ="+g);

                   g.drawRect(130,30,40,40); //Draw head

                   g.drawLine(150,70,150,80); //draw neck

                  g.drawRect(100,80,100,150); //draw body

                   g.drawLine(200,130,250,130); //draw right arm

                   g.drawLine(250,130,250,70);

                   g.drawLine(100,130,40,190); //draw left arm

                    g.drawLine(125,230,95,320); //draw left leg

                    g.drawLine(95,320,75,320);

                    g.drawLine(175,230,205,320); //draw right leg

                   g.drawLine(205,320,225,320);

            }

           public static void main(String args[]){

                    StickFigure frame=new StickFigure();

                   frame.setTitle("Stick Figure");

                   frame.setSize(300,350);

                   frame.show();

         }

}

Add a comment
Know the answer?
Add Answer to:
Im trying to create a program in java where I draw a stick figure, when you click on the stick figure it should get larger.   And you should be able to drag it.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA HELP Create a small program where You ask the user The amount of money he/she...

    JAVA HELP Create a small program where You ask the user The amount of money he/she wants to convert using GUI Pop up input (import javax.swing.JOptionPane;) The first pop up should ask the user to what currency he/she wants to convert, He needs to be able to click that option, The currency you should use are : Euros , Pesos , Yen , Pound , Ruble, Quetzal, Once the user Clicks the option It will ask The amount the user...

  • In Java Please Create A Program For The Following; Please Note: This program should be able...

    In Java Please Create A Program For The Following; Please Note: This program should be able accept changes to the values of constants ROWS and COLS when testing the codes. Switch2DRows Given a 2D array with ROWS rows and COLS columns of random numbers 0-9, re-order the rows such that the row with the highest row sum is switched with the first row. You can assume that 2D arrau represents a rectangular matrix (i.e. it is not ragged). Sample run:...

  • USING JAVA, Use the binary search algorithm to create a game where you think of the...

    USING JAVA, Use the binary search algorithm to create a game where you think of the number and the computer guesses it. The computer should be able to guess any number between 1 and 500. When the computer chooses a number, you need to tell it if the guess is too high or too low. Have the program print out the number of guesses that it took to guess the number.

  • Hello there, So I got an assignment that I just cant get further with. So trying...

    Hello there, So I got an assignment that I just cant get further with. So trying to start from scratch again.. So im supposed to make a class with a UML aswell and a main file. This is how far ive came, https://imgur.com/a/MGqUN , Thats the car class code and the UML. This is the assignment Make a program where you can handle different cars at a car company. The user should be able to choose do the following: a)...

  • Im trying to create a function in C where it takes an array and size and...

    Im trying to create a function in C where it takes an array and size and returns the largest absolute value in the array (either negative or positive). Any help would be greatly appreciated! Ex: if the array is { -2.5, -10.1, 5.2, 7.0}, it should return -10.1 Ex: if the array is {5.1, 2.3, 4.9, 1.0}, it should return 5.1. double getMaxAbsolute(double array[], int size) {     double max = array[0];    double abs[size];    for (int i =...

  • Im trying to create a craps game on linux mint but im definitely not proficient with...

    Im trying to create a craps game on linux mint but im definitely not proficient with it. I'm a new student to this class and its done online. I seen a post that was already made with the exact question and requirements that I need to use for my script, but when I run the command it processes wrong, it goes like this... Name the script craps.sh The script will get 2 random numbers between 1-6. The script will display...

  • I should use the array and loop to create a java program according to the instruction,...

    I should use the array and loop to create a java program according to the instruction, but I have no idea how to do it. Introduction This lab assignment continues to give you practice using loops, particularly loops with variable termination conditions, and it also provides you an opportunity to use one-dimensional arrays. Recall that an array is used to store a collection of data. The data can be values of Java primitive data types or else objects (for instance,...

  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

  • Write a Java program that implements the number guessing game where the computer tries to guess...

    Write a Java program that implements the number guessing game where the computer tries to guess a number in your head. You pick a number between 0 and 100, and the computer generates a guess. You then type 1 if your number is larger than the computer’s guess, -1 if your number is smaller, and 0 if the number is correct. The computer should keep trying to guess the number by adjusting the guess based on your feedback (so if...

  • Write a python program where you create a list (you an create it in code you...

    Write a python program where you create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December). The program should calculate and display the: 1) total rainfall for the year; 2) the average monthly rainfall; 3) the months with the highest and lowest amounts. You need to figure out how to access each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT