Question
I need help with the following assignment: In the assignment you will gain experience with the following: Swing Event handling in Swing Swing Timers The
I need help with the following assignment:
In the assignment you will gain experience with the following:
Swing
Event handling in Swing
Swing Timers
The assignment requires to utilize the above mentioned packages to track the mouse position. There should be a turtle created in a new world. Whenever the mouse is positioned in the world, the turtle should slowly begin moving towards the position of the mouse. It will continue to move towards the mouse until it reaches it, or the mouse exits the world. We must use a timer to control the speed of the turtle!
There are 2 different interfaces you will need for handling mouse events.
As noted above you need to have the turtle start/stop moving based on:
Whether it is already at the position of the mouse
If the mouse pointer is in the drawing area. This latter one can be handled by using the Point object that the TurtleMouseFollower has.
In my implementation I initially set it to null and reset it to nullwhen the mouse exits the drawing area.
cop2513.turtlemoussefollow: Main +main(StringO args): void edu support: EndWorld cop2513.turtlemousefollow: TurtleMouseFollower edu.gatech.mediacomp: Turtle -FORWARD PIXELS: int +TurtleMouseFollower(): ctor javax.swing: Timer java awt: PointStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started