views:

42

answers:

2

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

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

I want it above the track, not on it.

A: 

If you mean, how can you set the current value of the JSlider, you should read the API and see that you can use setValue. The question sounds confusing because you use the terms pointer and offset, which typically carry a completely different meaning in programming.

Amir Afghani
I do not mean current value. I mean, how can I move the pointer away from the bar so its not on top.
Landmine
In that case, I think you want setExtent.
Amir Afghani
I'll, look into that. Thank you.
Landmine
I updated my first post to help communicate my question.
Landmine
+1  A: 

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.

camickr
Thank you for your help
Landmine