Dimension () { Dimension size = super.getPreferredSize(); Container parent = getParent(); Insets insets = parent.getInsets(); size.width = Math.min(parent.getWidth() - insets.left - insets.right - (parent.getComponentCount() == 2 ? parent.getComponent(1).getWidth() + JBUIScale.scale(20) : 0), size.width); return size; }