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

49
LINES

< > BotCompany Repo | #1015996 // DynSCP

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

Transpiled version (10225L) is out of date.

abstract sclass DynSCP extends DynModule {
  transient SingleComponentPanel scp;
  transient ReliableSingleThread rstRevisualize2 = new(r revisualize2_impl);
  transient L<Runnable> afterVisualize2;
  static bool verbose;

  /*final*/ JComponent visualize() {
    scp = singleComponentPanel();
    scp.setComponent(visualize2());
    pcallFAll(afterVisualize2);
    ret scp;
  }
    
  void unvisualize() { scp = null; unvisualize2(); }
  JComponent visualize2() { null; }
  
  void unvisualize2() {} // overridable
  
  void revisualize2() {
    rstRevisualize2.trigger();
  }
  
  void revisualize2_impl() enter {
    //lock lock;
    if (scp == null) ret;
    JComponent c = visualize2();
    if (c != scp.getComponent()) {
      if (verbose) print("Setting component");
      scp.setComponent(c);
      pcallFAll(afterVisualize2);
    }
  }
  
  void setComponent(Component c) {
    if (scp != null) scp.setComponent(c);
  }
  
  // usually it'll be a JComponent
  JComponent getComponent() {
    ret scp == null ? null : (JComponent) scp.getComponent();
  }
  
  bool isShowing() { ret scp != null; }
  bool isShowing(Component c) { ret isComponentShowing(c); }
  
  void afterVisualize2(Runnable r) {
    afterVisualize2 = createOrAddToSyncList(afterVisualize2, r);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1015996
Snippet name: DynSCP
Eternal ID of this version: #1015996/22
Text MD5: 16b58936d3e8b06e0332c589d9af2fd9
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-21 01:55:26
Source code size: 1325 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 598 / 1301
Version history: 21 change(s)
Referenced in: [show references]