abstract sclass DynSCP extends DynModule { transient SingleComponentPanel scp; transient ReliableSingleThread rstRevisualize2 = new(r revisualize2_impl); transient L afterVisualize2; static bool verbose; /*final*/ JComponent visualize() { scp = singleComponentPanel(); scp.setComponent(visualize2()); pcallFAll(afterVisualize2); ret scp; } void unvisualize() { scp = null; unvisualize2(); } JComponent visualize2() { null; } void unvisualize2() {} // overridable void revisualize2() { rstRevisualize2.trigger(); } void revisualize2_impl() enter { //lock lock; if (scp == null) ret; JComponent c = visualize2(); if (c != scp.getComponent()) { if (verbose) print("Setting component"); scp.setComponent(c); pcallFAll(afterVisualize2); } } void setComponent(Component c) { if (scp != null) scp.setComponent(c); } // usually it'll be a JComponent JComponent getComponent() { ret scp == null ? null : (JComponent) scp.getComponent(); } bool isShowing() { ret scp != null; } bool isShowing(Component c) { ret isComponentShowing(c); } void afterVisualize2(Runnable r) { afterVisualize2 = createOrAddToSyncList(afterVisualize2, r); } }