2
In my project I have a Jslider, its minimum value is 0 and its maximum value is 10. I would like to modify it so that its interval is two in two numbers, so that it is only possible to select/show even values. At the moment, I’m using the following code to do this:
int sliderValor = sliderFim.getValue();
//se não for par
if((sliderValor % 2 != 0))
{
sliderFim.setValue(++sliderValor);
}
lblFim.setText(Integer.toString(sliderValor));
Is there any better or more recommended way to do this?
I believe it’s setStep(2).
– user83428