Adding an adjustable rotating image to the Jslider.

The JSlider initially has only 1 degree of freedom (it translates to the track either horizontally or vertically). I want to add a second degree of freedom to the handle and manually rotate it. In other words, I want to be able to move the handle left and right and rotate it. Both of these movements must be set by dragging the mouse in a linear or rotational direction. I did not see the code for this, and I was wondering how I can do this.

+3
source share
1 answer

I would stretch BasicSliderUIand redefine the method paintThumbso that you can draw your thumb with arbitrary rotation, applying a rotation transformation to the thumb image, or manually rotating the thumb. Then apply this interface to your JSlider.

To control the rotation using the mouse and keyboard, it may be easiest to add MouseWheelListenerto JSlider so that you control the rotation of the thumb with the mouse wheel.

+1
source

All Articles