title: java rotate rectangle around the center
body: <p>I would like to rotate a rectangle around its center point and it should remain in the place that it is supposed be drawn and rotate in that space</p>
  
  <p>this is my code:</p>
  
  <pre><code>AffineTransform transform = new AffineTransform();
  
      transform.rotate(Math.toRadians(45),rectangle.width/2, rectangle.height/2);
      Shape transformed = transform.createTransformedShape(rectangle);
      g2.fill(transformed)
  </code></pre>
  
  <p>the rectangle is rotated but it is drawn at a different part of the screen, how can I correct this?</p>