Reputation: 199
I have a slider and it's max value is 60. How to show only 10, 25 and 60 as a label ?
Thanks in Advance!
Upvotes: 0
Views: 1050
Reputation: 36601
With the setLabelTable
method. Copy-paste from the tutorial:
//Create the slider
JSlider framesPerSecond = new JSlider(JSlider.VERTICAL,
FPS_MIN, FPS_MAX, FPS_INIT);
...
//Create the label table
Hashtable labelTable = new Hashtable();
labelTable.put( new Integer( 0 ), new JLabel("Stop") );
labelTable.put( new Integer( FPS_MAX/10 ), new JLabel("Slow") );
labelTable.put( new Integer( FPS_MAX ), new JLabel("Fast") );
framesPerSecond.setLabelTable( labelTable );
framesPerSecond.setPaintLabels(true);
Upvotes: 4