getting the shape to center at mouse coordinates

i am having a hard time getting this right.. i can rotate the rectangle but i can't make it move to the center of the mouse.. here's the code

privatevoid drawTempStructure(Graphics2D g2D)

{

Rectangle2D.Double rect =new Rectangle2D.Double();

Point2D.Double structCenter =new Point2D.Double();

Point2D.Double shapeCenter =new Point2D.Double();

Shape shape;

double theta = Math.toRadians(45);

Rectangle2D bounds;

structCenter.setLocation(mouseX, mouseY);

AffineTransform at = AffineTransform.getRotateInstance(theta, structCenter.getX(), structCenter.getY());

rect.setRect(structCenter.getX(), structCenter.getY(), structWidth, structHeight);

shape = at.createTransformedShape(rect);

bounds = shape.getBounds2D();

at.setToTranslation(bounds.getCenterX(), bounds.getCenterY());

g2D.draw(shape);

}

mouseX and mouseY are the coordinates of the mouse

[1208 byte] By [hardcodera] at [2007-11-26 22:05:08]
# 1

private void drawTempStructure(Graphics2D g2D) {

Rectangle2D.Double rect = new Rectangle2D.Double();

Point2D.Double structCenter = new Point2D.Double();

Point2D.Double shapeCenter = new Point2D.Double();

Shape shape;

double theta = Math.toRadians(45);

Rectangle2D bounds;

structCenter.setLocation(mouseX, mouseY);

AffineTransform at = AffineTransform.getRotateInstance(theta, structCenter.getX(), structCenter.getY());

rect.setRect(structCenter.getX()-structWidth/2, structCenter.getY()-structHeight/2, structWidth, structHeight);

shape = at.createTransformedShape(rect);

g2D.draw(shape);

}

Rodney_McKaya at 2007-7-10 10:49:03 > top of Java-index,Security,Cryptography...