Search code examples
javaoffsetjslider

How can I offset the pointer on a JSilder?


In Java how can I offset the knob from my JSilder track?

                \/
|------------------------------|

I want it above the track, not on it.


Solution

  • You would need to create a custom SliderUI.

    You would probably extend MetalSliderUI. The paintThumb() method is responsible for painting the thumb so you probably need to customize that method to change the Y offset of the thumb. You would then also need to change the preferred size calculation to account for this offset as well.