sclass JContentAndControls is Swingable, Updateable { settable IF0/**/ makeContent; SingleComponentPanel scpContent = singleComponentPanel(); ReliableSingleThread rstReloadContent = rst(l0 reloadImpl); settable JButton btnReload; gettable DynamicHStack controls = dynamicHStack(); gettable JPanel rightCornerControls = jline(); SingleComponentPanel scpControls = singleComponentPanel(jfullcenter(controls)); settable bool loadingScreenWhenReloading; settable bool showControls = true; settable bool showReloadButton = true; public void reload aka update() { rstReloadContent.trigger(); } cachedVisualize { onComponentShown(scpContent, -> { if (scpContent.isEmpty()) reload(); }); if (!showControls) ret scpContent; if (showReloadButton) { btnReload = jReloadButton(l0 reload); add(rightCornerControls, btnReload); } ret northAndCenter(withMargin( centerAndEastWithMargin(scpControls, rightCornerControls)), scpContent); } swappable JComponent makeLoadingScreen() { ret jCenteredLabel("Loading..."); } void reloadImpl { temp tempDisableButton(btnReload); if (loadingScreenWhenReloading() || !scpContent.hasComponent()) scpContent.set(makeLoadingScreen()); try { scpContent.set(wrap(makeContent?!)); } catch print e { scpContent.set(jErrorView(e)); } } selfType addControl(S label, JComponent etc control) { ret addControl(withLabel(label, control)); } selfType addControl(JComponent etc control) { controls.addComponent(control); this; } selfType content(IF0 makeContent) { ret makeContent(makeContent); } selfType addControlLine(JComponent newControls) { scpControls.set(centerAndSouthWithMargin(scpControls!, newControls); this; } }