Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

All snippets
Create a snippet
Full search

Quick search:


Editing Snippet ID: #1015996
Snippet name:
Category, Type:
Content:
abstract sclass DynSCP extends DynModule { transient SingleComponentPanel scp; transient ReliableSingleThread rstRevisualize2 = new(r revisualize2_impl); transient L<Runnable> 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); } }
Comment:
Public (visible to everyone):
Created: 2018-06-02 20:48:40

This page without fancy editor.