void (@NotNull Container parent) { if (myComponent == null) return; Dimension preferredSize = getPreferredSize(myComponent); int width = parent.getWidth(); int height = parent.getHeight(); myComponent.setBounds(0, 0, width, Math.min(height, preferredSize.height)); }