JComponent (Configurable configurable) { return configurable == null ? null : ReadAction.compute(() -> { JComponent component = null; long time = System.currentTimeMillis(); try { component = configurable.createComponent(); } catch (Exception unexpected) { LOG.error("cannot create configurable component", unexpected); } finally { warn(configurable, "create", time); } if (component != null) { reset(configurable); if (ConfigurableWrapper.cast(MasterDetails.class, configurable) == null) { if (ConfigurableWrapper.cast(Configurable.NoMargin.class, configurable) == null) { if (!component.getClass().equals(JPanel.class) && !component.getClass().equals(DialogPanel.class)) { // some custom components do not support borders JPanel panel = new JPanel(new BorderLayout()); panel.add(BorderLayout.CENTER, component); component = panel; } if (component.getLayout() instanceof GridLayout) { // GridLayout uses SpacingConfiguration.verticalComponentGap = 6 as a part of components component.setBorder(JBUI.Borders.empty(5, 16, 10, 16)); } else{ component.setBorder(JBUI.Borders.empty(11, 16, 16, 16)); } } if (ConfigurableWrapper.cast(Configurable.NoScroll.class, configurable) == null) { JScrollPane scroll = ScrollPaneFactory.createScrollPane(null, true); scroll.setViewport(new GradientViewport(component, JBUI.insetsTop(5), true)); scroll.getVerticalScrollBar().setBackground(JBColor.PanelBackground); scroll.getHorizontalScrollBar().setBackground(JBColor.PanelBackground); component = scroll; } } } return component; }); }