Is there a way to flip a JSlider so that the slider arrow points upwards?

99封情书 提交于 2019-12-23 15:15:53

问题


I've been trying to find a way to do this for a while now and can't quite seem to figure it out. I know you can change the orientation of a JSlider, using setOrientation(HORIZONTAL|VERTICAL), and that you can also invert the scale, using setInverted(true). My problem is as follows:

1) The JSlider needs to be horizontal;
2) The JSlider needs to be below the data;
3) The arrow (pointy-tip) on the actual slider should be pointing upwards, not downwards (i.e.: towards the data).

The only way I can fathom to do this is to overwrite the paintComponent method from JComponent and entirely re-code it for a custom JSlider, which seems a tad ridiculous, and I'm not even sure it would work.

Thanks for the help!


回答1:


You can override the thumbnail used in UIManager How to hide the knob of jSlider?

UIManager.getLookAndFeelDefaults().put(
    "Slider.horizontalThumbIcon",
    new Icon('your_icon')
);

However, this would be done to all sliders in your program.



来源:https://stackoverflow.com/questions/4027289/is-there-a-way-to-flip-a-jslider-so-that-the-slider-arrow-points-upwards

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