void (JComponent c) { boolean doRevalidate = false; if (myHeaderComponent != null) { myHeaderPanel.remove(myHeaderComponent); myHeaderComponent = null; doRevalidate = true; } if (c != null) { myHeaderPanel.add(c, BorderLayout.CENTER); myHeaderComponent = c; if (isVisible()) { final Dimension size = myContent.getSize(); if (size.height < c.getPreferredSize().height * 2) { size.height += c.getPreferredSize().height; setSize(size); } } doRevalidate = true; } if (doRevalidate) myContent.revalidate(); }