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

21
LINES

< > BotCompany Repo | #1036372 // jOnDemandInQ - generate component only when shown, use a specified queue to generate

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (14726L/85K).

static SingleComponentPanel lambda0Like jOnDemandInQ(Q q, IF0<JComponent> makeComponent) {
  SingleComponentPanel scp = singleComponentPanel();
  bindToComponent(scp, -> {
    if (!scp.isEmpty()) ret;
    
    runInQ(q, -> {
      if (!scp.isEmpty()) ret;

      try {
        var c = makeComponent?!;
        swing {
          if (!scp.isEmpty()) ret;
          scp.setComponent(c);
        }
      } catch print e {
        scp.setComponent(jscroll(jFastLogView_noWrap(renderStackTrace(e)));
      }
    });
  }, null);
  ret scp;
}

Author comment

Began life as a copy of #1034024

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036372
Snippet name: jOnDemandInQ - generate component only when shown, use a specified queue to generate
Eternal ID of this version: #1036372/4
Text MD5: b27a6016aa467863990e352490c5d5ba
Transpilation MD5: 245b4ba52c809605e3c23621bf09defb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-28 17:59:03
Source code size: 554 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 196
Version history: 3 change(s)
Referenced in: [show references]