JPanel (@Nullable @NlsContexts.Separator String title, PaintAwarePanel content, int indentLevel, @NotNull Consumer<JPanel> configuration) { JPanel result = new JPanel(new GridBagLayout()); if (title != null) { GridBag constraints = ExternalSystemUiUtil.getFillLineConstraints(indentLevel); constraints.insets.top = UIUtil.LARGE_VGAP; result.add(new TitledSeparator(title), constraints); } int count = result.getComponentCount(); configuration.accept(result); if (result.getComponentCount() > count) { content.add(result, ExternalSystemUiUtil.getFillLineConstraints(0).insets(0, 0, 0, 0)); } return result; }