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

23
LINES

< > BotCompany Repo | #1034897 // awtCalcContinuously

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

Libraryless. Click here for Pure Java version (9699L/54K).

static <A extends JComponent> A awtCalcContinuously(A component, Runnable runnable) {
  if (runnable == null) ret component;
  
  new SingleThread thread;
  new BoolVar visible;
  var info = _threadInfo();
  Runnable theLoop = r {
    _threadInheritInfo(info);
    while ping (visible!) {
      try {
        runnable.run();
      } catch print e {
        sleepSeconds(1); // error penalty
      }
    }
  };
  
  bindToComponent(component,
    -> { visible.set(); thread.go(theLoop); },
    -> visible.clear());

  ret component;
}

Author comment

Began life as a copy of #1006234

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, iveijnkanddl, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034897
Snippet name: awtCalcContinuously
Eternal ID of this version: #1034897/8
Text MD5: 9044c45cd2f0e0b7c44ab019edcfdae0
Transpilation MD5: 2fcdd50a933883d754294163059cd953
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-27 05:29:19
Source code size: 555 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 70 / 129
Version history: 7 change(s)
Referenced in: [show references]