有没有办法翻转 JSlider,使滑块箭头指向上方? [英] Is there a way to flip a JSlider so that the slider arrow points upwards?

查看:25
本文介绍了有没有办法翻转 JSlider,使滑块箭头指向上方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直试图找到一种方法来执行此操作,但似乎无法完全弄清楚.我知道您可以使用 setOrientation(HORIZONTAL|VERTICAL) 更改 JSlider 的方向,并且您还可以使用 setInverted(true) 反转比例.我的问题如下:

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) JSlider 需要是水平的;
2)JSlider需要在数据下方;
3) 实际滑块上的箭头(尖头)应该指向上方,而不是下方(即:指向数据).

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).

我能理解的唯一方法是覆盖 JComponent 的 paintComponent 方法,并为自定义 JSlider 完全重新编码,这似乎有点荒谬,我什至不确定它是否有效.

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.

感谢您的帮助!

推荐答案

您可以覆盖 UIManager 中使用的缩略图 如何隐藏jSlider的旋钮?

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.

这篇关于有没有办法翻转 JSlider,使滑块箭头指向上方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆