For the jfoenix slider, the indicator always changed with the slider and show the value accordingly. How can we customize the value in indicate, for example when slide the value from 0-4 we want to show "Small" on the indicate.
Asked
Active
Viewed 693 times
1 Answers
3
I've digged out the answer by myself, just post it here in case someone else need that appreciate it if you can let me know some better ones. This one is for formatting the value in the indicator to one decimal point and of course you can add some logic to show some string based on the value.
yourSlider.setValueFactory(new Callback<JFXSlider, StringBinding>() {
@Override
public StringBinding call(JFXSlider arg0) {
return Bindings.createStringBinding(new java.util.concurrent.Callable<String>(){
@Override
public String call() throws Exception {
DecimalFormat df = new DecimalFormat("#.0");
return df.format(yourSlider.getValue());
}
}, yourSlider.valueProperty());
}
});

Kuku
- 484
- 8
- 28