title: Java 2d rotation in direction mouse point
body: <p>So far I have a java app where I draw a circle(player) and then draw a green rectangle on top(gun barrel). I have it so when the player moves, the barrel follows with it. I want it to find where the mouse is pointing and then rotate the barrel accordingly. For an example of what I mean look at this video I found <a href="http://www.youtube.com/watch?v=8W7WSkQq5SU" rel="nofollow noreferrer">http://www.youtube.com/watch?v=8W7WSkQq5SU</a> See how the player image reacts when he moves the mouse around?</p>
  
  <p>Here's an image of what the game looks like so far:</p>
  
  <p><img src="https://i.stack.imgur.com/jN2WR.png" alt="My Progress"></p>
  
  <p>So how do I rotate it like this? Btw I don't like using affinetransform or Graphics2D rotation. I was hoping for a better way. Thanks</p>