Rectangle (final MouseEvent e) { final int x = Math.min(myStartPoint.x, e.getX()); final int y = Math.min(myStartPoint.y, e.getY()); final int width = Math.abs(myStartPoint.x - e.getX()); final int height = Math.abs(myStartPoint.y - e.getY()); return new Rectangle(x, y, width, height); }