Question
GUI bouncing shapes program
te a lava program to implement the animated bouncing shapes graphics program that Writ was demonstrated in class. Square, an
use this interface

public interface BouncingShape / Change the position of the objects bounding box. void move /* * Dr aw the object in the give

the out put of the program should be a jFrame with three buttons: “add triangle”, “add square” and “add circle” and a blank screen. when the user clicks any of these buttons the corresponding shape appears and starts bouncing around the screen. the shape of these shaoes and randomized and anytime the user clicks the button you should be able to keeping adding shapes on the screen while the previosus shape is bouncing arounf the frame.
i have attached more detail of the program
Write a Java program to implement the anim ated bouncing shapes graphics program that demonstrated in class. Your GUI will co
te a lava program to implement the animated bouncing shapes graphics program that Writ was demonstrated in class. Square", an Icon object where the geometric shapes will be drawn. The Icon should 600 pixels wide and 400 pixels in height, and should contain a rectangle that shows its boundary. Clicking on any button will add the corresponding shape to the icon. Your GUI will consist of three buttons labeled "Add a "Add a Circle", and "Add a Triangle", and a JLabel containing
public interface BouncingShape / Change the position of the objects bounding box. void move /* * Dr aw the object in the given graphics context. eparam g2 the graphics context in which to draw or fill void draw (Graphics2D g2)
Write a Java program to implement the anim ated bouncing shapes graphics program that demonstrated in class. Your GUI will consist of three buttons labeled "Add a was re", "Add a Circle", and "Add a Triangle", and a JLabel containin an Icon object where the geometric shapes will be drawn. The Icon should 600 pixels wide and 400 pixels in height, and should contain a rectangle that shows its boundary Clicking on any button will add the corresponding shape to the icon All shape objects must implement the BouncingShape interface given at the end of this handout. Each shape must have the following characteristics: When a shape is constructed, its original location should be the upper-left corner of the Icon Each shape should be constructed in square bounding box. The size of each bounding box should be determined when the shape is constructed by calculating a random integer in the range 10. 100 In addition to its size, each new shape should calculate two random integer values (dx and dy) in the range 1-5. These values represent the amounts that the object will shift in the x- and y-direction each time it is told to move. When the BouncingShape's move () method is called, your program should: Determine if adding dx and dy to the upper-left coordinate of the shape's bounding box will cause any part of the shape to move outside of the icon area. If so, multiply the dx and/or dy value (as appropriate) by -1 to reverse the direction of movement on that axis o o Add the values of dx and dy to the upper-left coordinate of the shape Each new shape should choose a color for itself when it is constructed by generating three random integers in the appropriate range and then creating a Color object using those values. Set the pen color to this value before you call draw() or fill() for that object. Animation should be controlled by a Timer object that fires 24 times/second (approximatly every 42 msecs). Each time the Timer executes its listener, the shape container object should move each BouncingShape and then repaint () the label Place all source files except the main class in an appropriately named package
0 0
Add a comment Improve this question Transcribed image text
Answer #1

imgal Sal aplet Appice 3 setcolor Cckor ved) 3dausti ing C wel come, 50-50) Ave C2to,ISO180 , 30,0,196) RU htmlつ < bodyつ hagt​​​​​​

Add a comment
Know the answer?
Add Answer to:
GUI bouncing shapes program use this interface the out put of the program should be a jFr...
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
  • This is python3. Please help me out. Develop the following GUI interface to allow the user...

    This is python3. Please help me out. Develop the following GUI interface to allow the user to specify the number of rows and number of columns of cards to be shown to the user. Show default values 2 and 2 for number of rows and number of columns. The buttons "New Game" and "Turn Over" span two column-cells each. Fig 1. The GUI when the program first starts. When the user clicks the "New Game" button, the program will read...

  • Java Programming .zip or .jar with 4 files: Shape.java, Square.java, TSquare.java, Triangle.java In this homework, you w...

    Java Programming .zip or .jar with 4 files: Shape.java, Square.java, TSquare.java, Triangle.java In this homework, you will build the below hierarchy: Overview: You will implement the supplier code: Shape, Square, TSquare, and Triangle, which will be used by the Homework7Main program. This program will use the DrawingPanel to draw these objects onto a canvas. Specification: You will take advantage of inheritance with using a super class, Shape.java. (below) Shape is an abstract class, which means it can be extended, but...

  • GUI in java: Run the below code before doing the actionlistener: import java.awt.*; import javax.swing.*; public...

    GUI in java: Run the below code before doing the actionlistener: import java.awt.*; import javax.swing.*; public class DrawingFrame extends JFrame {    JButton loadButton, saveButton, drawButton;    JComboBox colorList, shapesList;    JTextField parametersTextField;       DrawingFrame() {        super("Drawing Application");        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        JToolBar toolbar = new JToolBar();        toolbar.setRollover(true);        toolbar.add(loadButton=new JButton("Load"));        toolbar.add(saveButton=new JButton("Save"));        toolbar.addSeparator();        toolbar.add(drawButton=new JButton("Draw"));               toolbar.addSeparator();        toolbar.addSeparator();        toolbar.add(new...

  • Modify the NervousShapes program so that it displays equilateral triangles as well as circles and rectangles....

    Modify the NervousShapes program so that it displays equilateral triangles as well as circles and rectangles. You will need to define a Triangle class containing a single instance variable, representing the length of one of the triangle’s sides. Have the program create circles, rectangles, and triangles with equal probability. Circle and Rectangle is done, please comment on your methods so i can understand */ package NervousShapes; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import javax.swing.*; import javax.swing.event.*; public class...

  • In Java. Write a GUI contact list application. The program should allow you to input names...

    In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...

  • Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by...

    Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...

  • Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...

    Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...

  • Q2) Interface Create a program that calculates the perimeter and the area of any given 2D...

    Q2) Interface Create a program that calculates the perimeter and the area of any given 2D shape. The program should dynamically assign the appropriate calculation for the given shape. The type of shapes are the following: • Quadrilateral 0 Square . Perimeter: 4xL • Area:LXL O Rectangle • Perimeter: 2(L+W) • Area:LxW Circle Circumference: I x Diameter (TT = 3.14) Area: (TT xD')/4 Triangle (assume right triangle) o Perimeter: a+b+c O Area: 0.5 x base x height (hint: the base...

  • [Continued] Your Course class should have: 1)a getter for the course 'code', so that it is...

    [Continued] Your Course class should have: 1)a getter for the course 'code', so that it is read-only; 2)a getter and setter for the lecturer attribute, so that it is readable and writable; 3)a constructor that creates the associations shown in the UML diagram; 4)an enrolStudent method that adds a given Student object into the 'enrolled' set; 5)a withdrawStudent method that removes a given Student object from the 'enrolled' set and returns true if the student was successfully found and removed,...

  • Java Painter Class This is the class that will contain main. Main will create a new...

    Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor.  Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...

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