Dimension () { final String text = myLabel.getText(); if (text == null || text.trim().isEmpty()) { return JBUI.emptySize(); } final Dimension preferredSize = super.getPreferredSize(); if (useHeaderInsets) { preferredSize.height = myLabel.getPreferredSize().height; } else { preferredSize.height = JBUI.CurrentTheme.Popup.headerHeight(containsSettingsControls()); } int maxWidth = JBUIScale.scale(350); if (!obeyPreferredWidth && preferredSize.width > maxWidth) { // do not allow caption to extend parent container return new Dimension(maxWidth, preferredSize.height); } return preferredSize; }