Pergunta

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!

Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top