Change displayable labels for a JSlider?
I have a JSlider with a min of 0 and a max of 10,000. I have the major tick marks set at 1,000. If I were to paint the labels now they would show up as 0, 1000, 2000, 3000, 4000, etc. What I would like to be shown would be 0, 1, 2, 3, 4, 5, etc. What would be a good way to accomplish this task? using JSlider.setLabelTable(Dictionary) EDIT Alternatively you can rely on predefined label UI and just change the label text: Enumeration e = jSlider.getLabelTable().keys(); while (e.hasMoreElements()) { Integer i = (Integer) e.nextElement(); JLabel label = (JLabel) jSlider.getLabelTable().get(i);