Set the size of a JSlider thumb

佐手、 提交于 2019-11-29 06:32:51

You could try customizing the 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:

It's important to note that these changes will apply to all JSlider instances, which may make this approach undesirable.

This depends on the SliderUI, which might have hard coded sizes. If not, using mre`s suggestion would be a way to go, if you want the same thumb size for all sliders.

Alternatively to setting the defaults for a UI that uses them, you could define a different UI for a special slider (e.g. myslider.setUI(new MyCustonSliderUI())), but be aware that that has its own drawbacks.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!