有没有办法翻转 JSlider 使滑块箭头指向上方?
我已经尝试找到一种方法来做到这一点有一段时间了,但似乎不太明白。我知道您可以使用 setOrientation(HORIZONTAL|VERTICAL) 更改 JSlider 的方向,并且还可以使用 setInverted(true) 反转比例。我的问题如下:
1)JSlider需要水平;
2)JSlider需要位于数据下方;
3) 实际滑块上的箭头(尖头)应指向上方,而不是指向下方(即:朝向数据)。
我能想到的唯一方法是覆盖 JComponent 中的 PaintComponent 方法,并为自定义 JSlider 完全重新编码,这似乎有点荒谬,我什至不确定它是否有效。
感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以覆盖 UIManager 中使用的缩略图 如何隐藏 jSlider 的旋钮?
但是,这将对程序中的所有滑块执行。
You can override the thumbnail used in UIManager How to hide the knob of jSlider?
However, this would be done to all sliders in your program.