Java Slider - how to make custom ticks?

不羁的心 提交于 2019-12-11 09:01:55

问题


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?


回答1:


I had this problem and didn't find a way to customise the tick spacing in JSlider.

You can use custom tick labels as a work-around, using JSlider.setLabelTable(). This allows you to label only certain ticks.



来源:https://stackoverflow.com/questions/929593/java-slider-how-to-make-custom-ticks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!