void (@NotNull JButton button, int noScaleWidth) { button.setPreferredSize(null); int width = JBUIScale.scale(noScaleWidth); if (button instanceof JBOptionButton && button.getComponentCount() == 2) { width += button.getComponent(1).getPreferredSize().width; } else { Border border = button.getBorder(); if (border != null) { Insets insets = border.getBorderInsets(button); width += insets.left + insets.right; } } button.setPreferredSize(new Dimension(width, button.getPreferredSize().height)); }