I'm trying to modified this JSLider function
public JSlider getSlider(int min, int max, int init, int mjrTkSp, int mnrTkSp) {
JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, init);
slider.setPaintTicks(true);
slider.setMajorTickSpacing(mjrTkSp);
slider.setMinorTickSpacing(mnrTkSp);
slider.setPaintLabels(true);
slider.addChangeListener(new SliderListener());
return slider;
}
I would like to set a range of min 0 and max 1 but I want to be able to return 0.1 , 0.2 , 0.3 to maximum 1 ( depends on the user slide value )
So I tried sliderR = getSlider(0, 1, 0, 50, 5);
Unfortunately this will only return 0 OR 1 , but I want to be able to return 0 , 0.1 0.2 0.3 etc..
Thank you
My idea is the following: instead of stepping by 0.1 from 0 to 1, step by 1 from 0 to 10. Then, simply divide the value by 10 e.g. in the ChangeListener
or whereever you need that value.