在 Swing 中叠加多个 JSlider
是否可以覆盖多个 JSlider,以便我可以看到两者上的“拇指”(我已尝试禁用轨道的绘制并将不透明度设置为 false,但其中一个仍然隐藏另一个)?基本上我想创建一个允许用户定义范围的组件(而且我真的不想编写自定义组件,因为它具有滑块的大部分属性)。如果有另一种方法可以用滑块来做到这一点,那也可以。
谢谢,
杰夫
Is it possible to overlay multiple JSliders so I can see the "thumbs" on both (I've tried disabling the painting of the track and setting opacity to false but one still hides the other)? Basically I'd like to create a component that allows the user to define a range (and I didn't really want to write a custom one since it has most of the attributes of a slider). If there is another way I could do that with a slider, that would work too.
thanks,
Jeff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
啊,我找到了(我一定没有以正确的条件进行搜索)。 Swing 实验室作为 JXMultiThumbSlider 我认为可以解决这个问题。
http://swinglabs.org/ hudson/job/SwingX%20Weekly%20Build/javadoc/org/jdesktop/swingx/JXMultiThumbSlider.html
Ah, I found it (i must not have been seraching on the right terms). Swing labs as a JXMultiThumbSlider that I think will do the trick.
http://swinglabs.org/hudson/job/SwingX%20Weekly%20Build/javadoc/org/jdesktop/swingx/JXMultiThumbSlider.html
我最近遇到了同样的问题,我想要一个带有两个拇指的滑块。我没有深入研究它,我最终为了获得范围所做的只是简单地放置两个滑块,并在“onSliderChange”事件侦听器中阻止一个比另一个小而另一个比另一个大。我不相信 Swing 有两个拇指滑块,尽管它可能是一个很酷的新功能,所以我认为这是您最好的选择。
I recently had the same problem, I wanted a slider with two thumbs. I didn't get into it too much, and what I ended up doing to get the range is simply putting two sliders and in the "onSliderChange" event listener prevented one beeing smaller than the other and the other bigger than the one. I don't beleive Swing has a two-thumb-Slider, although it might be a cool new feature to add, so I think this is your best bet.
JIDE 在其开源公共层中有一个带有 2 个拇指的 RangeSlider(顶部还有一个很好的额外的拇指,可以同时移动两个拇指(例如,拖动范围):http://www.jidesoft.com/products/oss.htm
JIDE has a RangeSlider with 2 thumbs (and a nice extra one on top to move both thumbs at once (e.g. drag the range around) in their open source common layer: http://www.jidesoft.com/products/oss.htm