Set the size of a JSlider thumb

前端 未结 2 1848
自闭症患者
自闭症患者 2020-12-17 19:19

How can the size of the thumb be configured for a JSlider?

With the defaults, and a range for the JSlider of 256, the thumb is only a few p

2条回答
  •  生来不讨喜
    2020-12-17 20:05

    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:

    • Customizing a JSlider Look and Feel

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

提交回复
热议问题