Question: use java We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) The application draws Circles

use java
We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) The application draws Circles when the C key is pressed . . For this application, as soon as the ball is drawn it should start moving o The Circles should bounce off the perimeter of the frame The Circles of different color should bounce off each other, and when they do they should swap colors The Circle of same Color will merge together by absorbing the smaller circle into the bigger circle. The size and the direction of the larger circle may not change o ShapeDriver will now need a Timer, and will also need to implement the ActionListener interface o Add the following to you ShapeDriver class: import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ShapeDriver implements ActionListener private Timer timer public ShapeDriver) /l the second argument to the Timer Constructor takes an ActionListener /l the this key word informs the JVM to look inside this class for // the actionPerformed method that must be overridden when /l ActionListener is implemented /l Every tick of the clock will now run the actionPerformed method timer = new Timer(1000/bo, this); timer.start); /l Method that must be implemented since the class implements ActionListener public void actionPerformed(ActionEvent e) // move each circle // check if circle is in bounds, and bounce off the borders if need be Il check if circle hits another circle of different color, /l bounce circles off each other and swap colors We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) The application draws Circles when the C key is pressed . . For this application, as soon as the ball is drawn it should start moving o The Circles should bounce off the perimeter of the frame The Circles of different color should bounce off each other, and when they do they should swap colors The Circle of same Color will merge together by absorbing the smaller circle into the bigger circle. The size and the direction of the larger circle may not change o ShapeDriver will now need a Timer, and will also need to implement the ActionListener interface o Add the following to you ShapeDriver class: import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ShapeDriver implements ActionListener private Timer timer public ShapeDriver) /l the second argument to the Timer Constructor takes an ActionListener /l the this key word informs the JVM to look inside this class for // the actionPerformed method that must be overridden when /l ActionListener is implemented /l Every tick of the clock will now run the actionPerformed method timer = new Timer(1000/bo, this); timer.start); /l Method that must be implemented since the class implements ActionListener public void actionPerformed(ActionEvent e) // move each circle // check if circle is in bounds, and bounce off the borders if need be Il check if circle hits another circle of different color, /l bounce circles off each other and swap colors
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
