I am trying to code my way into displaying in a label(like a tooltip) the current value of a position in a slider when I drag the slider thumb. For example: if a slider has Integer values from 0 to 100, and I drag the slider thumb to the middle of the slider, a small popup will show me that I am currently in position 50.
So far, that's what I managed to do:
final Label textLabel = new Label("Volume");
final Slider volumeSlider = new Slider();
volumeSlider.valueProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue arg0, Object arg1, Object arg2) {
textLabel.textProperty().setValue(
String.valueOf((int) volumeSlider.getValue()));
}
});
root.getChildren().addAll(volumeSlider, textLabel);
textLabel.textProperty().setValue("abc");
It doesn't display on screen the values.
Also, if any of you happen to know, how do I set a starting point in a slider track? Like, if I wanted the program to start and the slider thumb to start in the middle of the slider(value 50) instead of starting on the lowest part.