0

In my applet I have an object to make a rectangle anywhere on the screen. All I need is a way to be able to send in the coordinates of my mouse and then let the rectangle rotate and point in that direction. What is the best way to accomplish rotating an object such as a rectangle to my mouse at any given point?

Maybe something to this degree except in applet form: Rotate a Java Graphics2D Rectangle?

Community
  • 1
  • 1
JWPM77
  • 5
  • 3
  • 1
    Why not simply use the code in the answer that you've linked to? Also, what have you tried? How is it not working? Without seeing the fruits of your efforts, it will be difficult for us to guess what you might be stuck on. – Hovercraft Full Of Eels May 19 '14 at 20:43
  • I don't think you're trying to do this, but just in case: A mouse does not produce any angular position information, and hence you cannot twist the mouse and expect to track that. A mouse can only move in an X-Y coordinate system. – Hot Licks May 19 '14 at 20:53
  • Why code an applet? If it is due to spec. by teacher, please refer them to [Why CS teachers should stop teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). – Andrew Thompson May 19 '14 at 21:06
  • @Hot Licks I do not want it to rotate as the mouse rotates but as the mouse moves around the object such as a cannon pointing to where the mouse is and firing a round. – JWPM77 May 19 '14 at 21:26

0 Answers0