In my project I have a JSlider, that 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 only being possible to select / display values pairs. 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?