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

38
LINES

< > BotCompany Repo | #1005426 // jCheckBox - make JCheckBox

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

Libraryless. Click here for Pure Java version (5747L/32K).

1  
static JCheckBox jCheckBox() {
2  
  ret swingNu(JCheckBox);
3  
}
4  
5  
static JCheckBox jCheckBox(bool checked) {
6  
  ret swingNu(JCheckBox, "", checked);
7  
}
8  
9  
static JCheckBox jCheckBox(S text, bool checked) {
10  
  ret swingNu(JCheckBox, text, checked);
11  
}
12  
13  
static JCheckBox jCheckBox(S text) {
14  
  ret swingNu(JCheckBox, text);
15  
}
16  
  
17  
static JCheckBox jCheckBox(S text, bool checked, O onChange) {
18  
  JCheckBox cb = jCheckBox(text, checked);
19  
  cb.setText(text);
20  
  ret cb;
21  
}
22  
  
23  
// onChange can be a Runnable or a voidfunc(bool)
24  
static JCheckBox jCheckBox(bool checked, fO onChange) {
25  
  final JCheckBox cb = jCheckBox(checked);
26  
  cb.addChangeListener(new ChangeListener {
27  
    public void stateChanged(ChangeEvent e) {
28  
      pcallF(onChange, cb.isSelected());
29  
    }
30  
  });
31  
  ret cb;
32  
}
33  
34  
static JCheckBox jCheckBox(bool checked, S text, IVF1<Bool> onChangeAndNow) {
35  
  var cb = jCheckBox(text, checked);
36  
  onChangeAndNow(cb, r { onChangeAndNow.get(isChecked(cb)); });
37  
  ret cb;
38  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005426
Snippet name: jCheckBox - make JCheckBox
Eternal ID of this version: #1005426/9
Text MD5: cf1dfc2160a0ea88b4b50d01cc83ec3c
Transpilation MD5: e3eb753b58a04c812d5f185eba8d1687
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-06 01:22:07
Source code size: 987 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 715 / 826
Version history: 8 change(s)
Referenced in: [show references]