Question

My JSlider first value is 0 and the last value is 8850. I want to set the major tick spacing so that the last value (8850) to be printed. For example if I set the major tick spacing to 550 the last value printed will be 8800.

Was it helpful?

Solution

You can use the JSlider#setLabelTable method to control which labels are painted. The JSlider#createStandardLabels avoids that you have to manually create all labels. It is sufficient to use that method to generate them for you, and just add your label for the max value to it.

The Swing slider tutorial even has sample code how to use custom labels

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top