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

21
LINES

< > BotCompany Repo | #1028019 // jCheckBoxMenuItem_dyn - with lambda getting value on show

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

Libraryless. Click here for Pure Java version (5004L/28K).

// IMPORTANT: doesn't work with JTattoo (so not currently in Stefan's OS). listeners are only called on first show+hide
// r : runnable or voidfunc(bool)
static JCheckBoxMenuItem jCheckBoxMenuItem_dyn(S text, IF0<Bool> checked, O r) {
  JCheckBoxMenuItem mi = jCheckBoxMenuItem(text, false, r);
  if (checked != null) bindToComponent(mi, r {
    bool b = isTrue(checked!);
    ifdef jCheckBoxMenuItem_dyn_debug
      print("jCheckBoxMenuItem_dyn: " + b + " " + text);
    endifdef
    setChecked(mi, b);
  }, r {
    ifdef jCheckBoxMenuItem_dyn_debug
      print("jCheckBoxMenuItem_dyn: hiding " + text);
    endifdef
  });
  ret mi;
}

static JCheckBoxMenuItem jCheckBoxMenuItem_dyn(S text, IF0<Bool> checked, IVF1<Bool> r) {
  ret jCheckBoxMenuItem_dyn(text, checked, (O) r);
}

Author comment

Began life as a copy of #1006523

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028019
Snippet name: jCheckBoxMenuItem_dyn - with lambda getting value on show
Eternal ID of this version: #1028019/9
Text MD5: d6f8ae28370ba505d71c1202ae5d598d
Transpilation MD5: 41807a1cf44bbb964888caa9cd0fba65
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-03 12:57:52
Source code size: 801 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 248 / 360
Version history: 8 change(s)
Referenced in: [show references]