Java – sets the size of the jslider

How do I configure the thumb size for jslider?

The default value is used, and the range of jslider is 256. The thumbnail is only a few pixels wide, which makes it very difficult to control with the mouse

I'm using the look and feel of Windows 7 as follows:

Enabling paintticks with primary and secondary scale spacing of 0 can display better (although not preferred):

The required display will be displayed in the following image – taken from the native Windows 7 Application:

Solution

You can try to customize jslider look and feel as follows:

UIDefaults defaults = UIManager.getDefaults();
defaults.put("Slider.thumbHeight",HEIGHT_AS_INTEGER); // change height
defaults.put("Slider.thumbWidth",WIDTH_AS_INTEGER); // change width

reference resources:

> Customizing a JSlider Look and Feel

Please note that these changes will apply to all jslider instances, which may make this method undesirable

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>