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).

1  
static SingleComponentPanel lambda0Like jOnDemandInQ(Q q, IF0<JComponent> makeComponent) {
2  
  SingleComponentPanel scp = singleComponentPanel();
3  
  bindToComponent(scp, -> {
4  
    if (!scp.isEmpty()) ret;
5  
    
6  
    runInQ(q, -> {
7  
      if (!scp.isEmpty()) ret;
8  
9  
      try {
10  
        var c = makeComponent?!;
11  
        swing {
12  
          if (!scp.isEmpty()) ret;
13  
          scp.setComponent(c);
14  
        }
15  
      } catch print e {
16  
        scp.setComponent(jscroll(jFastLogView_noWrap(renderStackTrace(e)));
17  
      }
18  
    });
19  
  }, null);
20  
  ret scp;
21  
}

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: 133 / 198
Version history: 3 change(s)
Referenced in: [show references]