public void hierarchyChanged(HierarchyEvent event) {
if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) {
JComponent component = (JComponent)event.getComponent();
final Demo demo = (Demo)component.getClientProperty("swingset3.demo");
if (!component.isShowing()) {
demo.stop();
} else {
getComponentByConstraint("demo").revalidate();
EventQueue.invokeLater(new Runnable() {
public void run() {
demo.start();