public static BasicDomElementComponent createComponentWithCaption( final CommittablePanel committablePanel, final CaptionComponent captionComponent, final DomElement element) { final JPanel panel = new JPanel(new BorderLayout()); panel.add(captionComponent, BorderLayout.NORTH); panel.add( element.isValid() ? committablePanel.getComponent() : new JPanel(), BorderLayout.CENTER); BasicDomElementComponent component = new BasicDomElementComponent(element) { @Override public JComponent getComponent() { return panel; } }; component.addComponent(committablePanel); component.addComponent(captionComponent); return component; }