Java Swing - 在 JSlider 上绘制标记
我有一个进度条,它继承自 JSlider 以提供突出显示功能。 突出显示可以添加到滑块的某个点(和颜色),然后将它们绘制到控件上。如下:
http://img101.imageshack.us/img101/7608/sliderexample.png
问题是我无法将突出显示放在正确的位置,它们需要与标记位于同一位置。我也不知道如何检索标记开始和结束位置的左右边距。
有没有办法获取每个标记的坐标?或者也许是执行此任务的更好方法?
非常感谢!
I have a progress bar which inherits from JSlider to provide highlighting functionality. Highlights can be added to the slider at a point (and a Color) and these are then painted onto the control. As follows:
http://img101.imageshack.us/img101/7608/sliderexample.png
The problem is that I cannot get the highlights in the right place, they need to be in the same location as the markers. I also do not know how to retrieve the left and right margins to where the markers start and end.
Is there anyway to get the coordinates of each marker? Or perhaps a better way of performing this task?
Many Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于外观和外观。感觉当用户使用一些非标准的 L&F 时,很有可能根本没有任何标记。事实上,您的问题既是功能扩展又是图形实现,因此您可能必须同时接触 JSlider 和 SliderUI。
请注意以下方法:
此外,研究 javax.swing.plaf.SliderUI 及其扩展类可能会有所帮助,尤其是
This is dependent on the Look & Feel and there's a good chance that there aren't any markers at all when the user uses some non-standard L&F. In fact, your problem is both an extension of functionality and graphic realization so you may have to touch both, JSlider and SliderUI.
Note the following methods:
Also, it may help to look into
javax.swing.plaf.SliderUI
and the classes extending it, especially