Rectangle () { if (isAltOptionPressed()) { // Alt/Option: Center selection around starting point int deltaX = Math.abs(myStartScreenX - myCurrentScreenX); int deltaY = Math.abs(myStartScreenY - myCurrentScreenY); return new Rectangle(myStartScreenX - deltaX, myStartScreenY - deltaY, 2 * deltaX, 2 * deltaY); } // Select diagonally from upper left to lower right return new Rectangle(myStartScreenX, myStartScreenY, 0, 0).union(new Rectangle(myCurrentScreenX, myCurrentScreenY, 0, 0)); }