void (boolean width, boolean height) { if (!isVisible() || !width && !height || isBusy()) return; Dimension size = getSize(); Dimension prefSize = myContent.computePreferredSize(); Point location = !myLocateWithinScreen ? null : getLocationOnScreen(); Rectangle screen = location == null ? null : ScreenUtil.getScreenRectangle(location); if (width) { size.width = prefSize.width; if (screen != null) { int delta = screen.width + screen.x - location.x; if (size.width > delta) { size.width = delta; } } } if (height) { if (size.width < prefSize.width) { if (!SystemInfo.isMac || Registry.is("mac.scroll.horizontal.gap")) { // we shrank horizontally - need to increase height to fit the horizontal scrollbar forHorizontalScrollBar(bar -> prefSize.height += bar.getPreferredSize().height); } } size.height = prefSize.height; if (screen != null) { int delta = screen.height + screen.y - location.y; if (size.height > delta) { size.height = delta; } } } final Window window = getContentWindow(myContent); if (window != null) { window.setSize(size); } }