void () { Content selected = contentManager.getSelectedContent(); if (selected == null) { contentComponent.removeAll(); return; } if (contentComponent.getComponentCount() == 1) { Component visible = contentComponent.getComponent(0); if (visible == selected.getComponent()) { return; } } JComponent replacement = selected.getUserData(Content.REPLACEMENT_COMPONENT); JComponent newComponent = replacement != null ? replacement : selected.getComponent(); contentComponent.removeAll(); contentComponent.add(newComponent, BorderLayout.CENTER); contentComponent.revalidate(); contentComponent.repaint(); }