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

20
LINES

< > BotCompany Repo | #1035158 // onSliderValueChanged

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

Libraryless. Click here for Pure Java version (7715L/43K).

1  
static JSlider onSliderValueChanged(JSlider slider, IVF1<Int> onChange) swing {
2  
  slider.addChangeListener(new ChangeListener {
3  
    int lastValue = slider.getValue();
4  
    public void stateChanged(ChangeEvent e) {
5  
      int value = slider.getValue();
6  
      if (value != lastValue) {
7  
        lastValue = value;
8  
        setToolTip(slider, str(value));
9  
        pcallF(onChange, value);
10  
      }
11  
    }
12  
  });
13  
  ret slider;
14  
}
15  
16  
static JSlider onSliderValueChanged(JSlider slider, Runnable onChange) {
17  
  if (onChange != null)
18  
    onSliderValueChanged(slider, runnableToIVF1(onChange));
19  
  ret slider;
20  
}

Author comment

Began life as a copy of #1031901

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1035158
Snippet name: onSliderValueChanged
Eternal ID of this version: #1035158/4
Text MD5: 4d17c722c548c5e0a7096fde55608cee
Transpilation MD5: 132364b94317ddf16fdef13741c9ee08
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-02 22:27:22
Source code size: 612 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 138 / 202
Version history: 3 change(s)
Referenced in: [show references]