Libraryless. Click here for Pure Java version (16271L/97K).
srecord noeq JOnDemandWithReloadButton(IF0<JComponent> 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; } }
Began life as a copy of #1034024
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036191 |
Snippet name: | JOnDemandWithReloadButton - generate component only when shown |
Eternal ID of this version: | #1036191/13 |
Text MD5: | cc21a4bf9b81a56ba7e4d51bad7ecf17 |
Transpilation MD5: | 50a45df00ef46cdf84c809971f33d0c2 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-12-11 18:46:57 |
Source code size: | 1301 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 188 / 295 |
Version history: | 12 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) #1036368 - G22ScriptView #1036474 - JContentAndControls |