void (int width, int height, @Nullable Point initial) { if (LOG.isDebugEnabled()) { LOG.debug("Setting the size (" + width + "," + height + ") for location " + initial); } Point location = initial != null ? initial : getLocation(); if (initial == null && LOG.isDebugEnabled()) { LOG.debug("Falling back to the actual location because the specified one is null: " + location); } Rectangle rect = new Rectangle(location.x, location.y, width, height); Rectangle before = null; if (LOG.isDebugEnabled()) { before = new Rectangle(rect); } fitToScreen(rect); if (LOG.isDebugEnabled() && !Objects.equals(before, rect)) { LOG.debug("Fitted these bounds to the screen: " + before + " -> " + rect); } if (initial != null || location.x != rect.x || location.y != rect.y) { if (LOG.isDebugEnabled()) { LOG.debug("Setting the location to (" + rect.x + "," + rect.y + ")"); } setLocation(rect.x, rect.y); } if (LOG.isDebugEnabled()) { LOG.debug("Setting the size to (" + rect.width + "," + rect.height + ")"); } super.setSize(rect.width, rect.height); }