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

23
LINES

< > BotCompany Repo | #1017125 // bindCheckBoxToLiveValue

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

Libraryless. Click here for Pure Java version (6416L/36K).

meta-for SimpleLiveValue also as IVarWithNotify {
  static <A extends JCheckBox> A bindCheckBoxToLiveValue(A cb, SimpleLiveValue<Bool> lv) {
    bindChangeListenerToComponent(cb, lv, r {
      ifdef bindCheckBoxToLiveValue_debug
        print("bindCheckBoxToLiveValue: setting " + isTrue(lv!));
      endifdef
      setChecked(cb, isTrue(lv!));
      ifdef bindCheckBoxToLiveValue_debug
        print("bindCheckBoxToLiveValue: setting done");
      endifdef
    });
    onChange(cb, r {
      ifdef bindCheckBoxToLiveValue_debug
        print("bindCheckBoxToLiveValue: setting 2: " + isChecked(cb));
      endifdef
      lv.set(isChecked(cb));
      ifdef bindCheckBoxToLiveValue_debug
        print("bindCheckBoxToLiveValue: setting 2 done");
      endifdef
    });
    ret cb;
  }
}

Author comment

Began life as a copy of #1016619

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017125
Snippet name: bindCheckBoxToLiveValue
Eternal ID of this version: #1017125/6
Text MD5: 15b4a409cefd49f99fcaecf2c816065b
Transpilation MD5: d051dfba37cef3aa0f3c813858b19221
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-17 17:16:01
Source code size: 806 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 327 / 450
Version history: 5 change(s)
Referenced in: [show references]