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

14
LINES

< > BotCompany Repo | #1027539 // dm_boolFieldImageSwitch

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

Libraryless. Click here for Pure Java version (10281L/71K).

static JLabel mapMethodLike dm_boolFieldImageSwitch(S field, S offImageID, S onImageID, O... _) {
  optPar S offToolTip;
  optPar S onToolTip;
  SimpleLiveValue<Bool> lv = dm_fieldLiveValue(field);
  JLabel l = jimage(isTrue(lv!) ? onImageID : offImageID);
  onLeftClick(l, r { lv.set(!isTrue(lv!)); });
  bindLiveValueListenerToComponent(l, lv, r {
    bool b = isTrue(lv!);
    setImage(b ? onImageID : offImageID, l);
    S toolTip = b ? onToolTip : offToolTip;
    if (toolTip != null) setToolTip(l, toolTip);
  });
  ret l;
}

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: #1027539
Snippet name: dm_boolFieldImageSwitch
Eternal ID of this version: #1027539/3
Text MD5: 93b80da4cf348a0a50b9e80770cae72f
Transpilation MD5: 99b97407c844d87299d0c73dadd5d2e4
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-23 13:44:08
Source code size: 543 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 203 / 301
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)