Java Slider - 如何制作自定义刻度? [英] Java Slider - how to make custom ticks?
问题描述
我有一个带有图像幻灯片的音轨 - 例如0:00 有图像 1,0:45 有图像 2,1:03 有图像 3,等等.我目前正在使用 JSlider 来改变轨道中的位置.我想在图像变化的点上的滑块上有刻度 - 但刻度之间的间距不均匀,所以 setPaintTicks
不是一个选项.有没有办法用 javax.swing.JSlider
做到这一点,或者你能推荐一个不同的滑块控件吗?
I have an audio track with an image slideshow - e.g. there's image 1 at 0:00, image 2 at 0:45, image 3 at 1:03 etc. I'm currently using a JSlider to change position in the track. I'd like to have ticks on the slider in the points where images change - but the spacing between ticks is not uniform, so setPaintTicks
is not an option. Is there a way to do this with javax.swing.JSlider
, or could you recommend a different slider control?
推荐答案
我遇到了这个问题并且没有找到在 JSlider 中自定义刻度间距的方法.
I had this problem and didn't find a way to customise the tick spacing in JSlider.
您可以使用自定义刻度标签作为变通方法,使用 JSlider.setLabelTable().这允许您仅标记某些刻度.
You can use custom tick labels as a work-around, using JSlider.setLabelTable(). This allows you to label only certain ticks.
这篇关于Java Slider - 如何制作自定义刻度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!