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

17
LINES

< > BotCompany Repo | #1031901 // liveSlider - also creates auto-tooltip (do we want that?)

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

Transpiled version (3600L) is out of date.

static JSlider liveSlider(int min, int max, int value, IVF1<Int> onChange) {
  ret swing(() -> {
    JSlider slider = new JSlider(min, max, value);
    slider.addChangeListener(new ChangeListener {
      int lastValue = slider.getValue();
      public void stateChanged(ChangeEvent e) {
        int value = slider.getValue();
        if (value != lastValue) {
          lastValue = value;
          setToolTip(slider, str(value));
          pcallF(onChange, value);
        }
      }
    });
    ret slider;
  });
}

Author comment

Began life as a copy of #1005725

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1031901
Snippet name: liveSlider - also creates auto-tooltip (do we want that?)
Eternal ID of this version: #1031901/2
Text MD5: 1d54cc6d99f8945aa09c758e055cd424
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-25 11:47:25
Source code size: 531 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 105 / 153
Version history: 1 change(s)
Referenced in: [show references]