void (JComponent component) { JComponent currentComponent = getComponent(); Container parent = currentComponent.getParent(); if (parent != null) { parent.remove(currentComponent); parent.add(component); } super.setComponent(component); }