Circle JSlider - Java 程序
有人可以向我展示设置 JSlider 的代码吗?除了它不是拇指而是一个圆圈之外?具体来说,它不是指向当前位置的小三角形,而是宽度为 100 的蓝色圆圈;
Can someone show me code that will set up a JSlider except, instead of a thumb, it is a circle? Specifically, instead of that little triangle which points to the current position, it is a blue circle of width 100;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您使用的是 Metal L&F,您可以扩展 javax.swing.plaf.metal.MetalSliderUI 并覆盖
horizThumbIcon
或vertThumbIcon
作为您的圆圈。然后使用slider.setUI()
将此 UI 设置为您想要的 UI,看看这里的答案,它对 JComboBox 执行更改 如何更改箭头样式JComboBox。
Assuming you're using the Metal L&F you could extend javax.swing.plaf.metal.MetalSliderUI and override the
horizThumbIcon
orvertThumbIcon
to be your circle. Then set this UI to be UI you'd like for your sider usingslider.setUI()
look at this the answer here which performs a change for a JComboBox How can I change the arrow style in a JComboBox.