1 | // f: voidfunc(float) |
2 | static JSlider liveSliderZeroToX(final float maxValue, final float def, fO f) { |
3 | ret swing(func -> JSlider { |
4 | final int max = 10000; |
5 | final float factor = max/maxValue; |
6 | final JSlider slider = new JSlider(0, max, iround(def*factor)); |
7 | slider.addChangeListener(new ChangeListener { |
8 | int lastValue = slider.getValue(); |
9 | public void stateChanged(ChangeEvent e) { |
10 | int value = slider.getValue(); |
11 | if (value != lastValue) { |
12 | lastValue = value; |
13 | float x = value/factor; |
14 | setToolTip(slider, str(x)); |
15 | pcallF(f, x); |
16 | } |
17 | } |
18 | }); |
19 | ret slider; |
20 | }); |
21 | } |
Began life as a copy of #1005725
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018694 |
Snippet name: | liveSliderZeroToX |
Eternal ID of this version: | #1018694/1 |
Text MD5: | 7be2a3311b9e0bcb60710fe054a40e2f |
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:16:51 |
Source code size: | 672 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 289 / 325 |
Referenced in: | [show references] |