Try to get the current look and feel of javax.swing.UIManager and name getUI(new JSlider()) on it. This should return the current user interface used for JSlider , which should be closed before JSliderUI .
Unfortunately, JSliderUI does not have a paintThumb(Graphics g) method, but BasicSliderUI does, and at least on Windows XP and Windows Vista, the appearance of the system is a subclass of BasicSliderUI , as is the Metal appearance.
So, as soon as you have JSliderUI , see if it is an instance of BasicSliderUI , so you can direct it to BasicSliderUI and use paintThumb(Graphics g) on it, otherwise the default is to use the way you do it already. I donβt know if this actually works, but it would be my first attempt if I needed it.
I don't have Linux or Mac to check the source if their JSliderUI also derived from BasicSliderUI , but if you do, check the java source code.
source share