srecord noeq JOnDemandWithReloadButton(IF0 makeComponent) is Swingable { SingleComponentPanel scp = singleComponentPanel(); ReliableSingleThread rstReload = rst(l0 reloadImpl); JButton btnReload; settable JPanel controls = rightAlignedLine(); SingleComponentPanel scpControlsMain = scp(); settable bool loadingScreenWhenReloading; settable bool showControls = true; void reload { rstReload.trigger(); } cachedVisualize { bindToComponent(scp, -> { if (scp.isEmpty()) reload(); }, null); if (!showControls) ret scp; makeControls(); ret northAndCenter(withMargin(centerAndEastWithMargin(scpControlsMain, controls)), scp); } void makeControls { if (!showControls) ret; btnReload = jReloadButton(l0 reload); controls.add(btnReload); } void reloadImpl { temp tempDisableButton(btnReload); if (loadingScreenWhenReloading() || !scp.hasComponent()) scp.setComponent(jCenteredLabel("Loading...")); try { scp.setComponent(makeComponent?!); } catch print e { scp.setComponent(jscroll(jFastLogView_noWrap(renderStackTrace(e))); } } selfType function(IF0 f) { makeComponent = -> wrap(f?!); this; } }