The knob of the JSlider originally has only 1 degree of freedom (it translates on the track either horizontally or vertically). I want to add a 2nd degree of freedom to the knob and manually rotate it. In other words, I want to be able to move the knob left and right AND rotate it. Both of these movements should be able to be set by either dragging the mouse in a linear or rotational direction. I havent seen code for this and was wondering how I could go about this.
Asked
Active
Viewed 433 times
1 Answers
1
I'd extend BasicSliderUI
and override the paintThumb
method so that you can paint your thumb at an arbitrary rotation, either by applying a rotation transform to the thumb image, or by manually drawing the thumb rotated. Then apply this UI to your JSlider.
To control the rotation with the mouse and keyboard, it may be easiest to add a MouseWheelListener
to the JSlider so that you control thumb rotation with the mouse wheel.

Julian Wright
- 705
- 4
- 13