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

20
LINES

< > BotCompany Repo | #1005725 // liveSliderZeroToOne

JavaX fragment (include)

// f: voidfunc(float)
static JSlider liveSliderZeroToOne(final float def, fO f) {
  ret swing(func -> JSlider {
    final int max = 9999;
    final JSlider slider = new JSlider(0, max, iround(def*max));
    slider.addChangeListener(new ChangeListener {
      int lastValue = slider.getValue();
      public void stateChanged(ChangeEvent e) {
        int value = slider.getValue();
        if (value != lastValue) {
          lastValue = value;
          float x = value/(float) max;
          setToolTip(slider, str(x));
          pcallF(f, x);
        }
      }
    });
    ret slider;
  });
}

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: 571 / 608
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1006955 - changeListener - make ChangeListener from runnable
#1015496 - jliveSlider
#1018690 - jLiveValueSlider (0 to 1, float)
#1018694 - liveSliderZeroToX
#1018839 - liveValueSpinner
#1024535 - rangeSliderZeroToOne
#1031901 - liveSlider - also creates auto-tooltip (do we want that?)