Rewrites setPosition function to keep the screen offsets, but change the position offsets for the bounding box.
@@ -346,8 +346,12 @@ public class Component {
throw new IllegalArgumentException("The y-axis position cannot be < 0.");
}
+ // Recalculate bounding box position:
+ final int x = boundingBox.x - this.position.x + position.x;
+ final int y = boundingBox.y - this.position.y + position.y;
+ this.boundingBox.setLocation(x, y);
+
this.position.setLocation(position);
- this.boundingBox.setLocation(this.position);
}
/**
