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

20
LINES

< > BotCompany Repo | #1005725 // liveSliderZeroToOne

JavaX fragment (include)

1  
// f: voidfunc(float)
2  
static JSlider liveSliderZeroToOne(final float def, fO f) {
3  
  ret swing(func -> JSlider {
4  
    final int max = 9999;
5  
    final JSlider slider = new JSlider(0, max, iround(def*max));
6  
    slider.addChangeListener(new ChangeListener {
7  
      int lastValue = slider.getValue();
8  
      public void stateChanged(ChangeEvent e) {
9  
        int value = slider.getValue();
10  
        if (value != lastValue) {
11  
          lastValue = value;
12  
          float x = value/(float) max;
13  
          setToolTip(slider, str(x));
14  
          pcallF(f, x);
15  
        }
16  
      }
17  
    });
18  
    ret slider;
19  
  });
20  
}

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: #1005725
Snippet name: liveSliderZeroToOne
Eternal ID of this version: #1005725/5
Text MD5: 5841ca4c09910d7e5e3a0c7bc23865c5
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-10 16:15:25
Source code size: 613 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 570 / 608
Version history: 4 change(s)
Referenced in: [show references]