import javax.swing.plaf.basic.BasicSliderUI; static void fixSliderScrolling(final JSlider s) { MouseListener[] listeners = s.getMouseListeners(); for (MouseListener l : listeners) s.removeMouseListener(l); // remove UI-installed TrackListener final BasicSliderUI ui = (BasicSliderUI) s.getUI(); BasicSliderUI.TrackListener tl = ui.new TrackListener() { // this is where we jump to absolute value of click @Override public void mouseClicked(MouseEvent e) { Point p = e.getPoint(); int value = ui.valueForXPosition(p.x); s.setValue(value); } // disable check that will invoke scrollDueToClickInTrack @Override public boolean shouldScroll(int dir) { return false; } }; s.addMouseListener(tl); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date |
---|---|---|---|
1246 | stefan | Doesn't work with Substance (not tried with standard Swing) | 2016-07-24 21:55:19 |
Snippet ID: | #1003646 |
Snippet name: | fixSliderScrolling |
Eternal ID of this version: | #1003646/1 |
Text MD5: | bf4235ca35067f830827ffa350f83b11 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-24 21:54:31 |
Source code size: | 784 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 830 / 802 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |