I am trying to update some information every time the Slider
value is changed, so I have the code set up like this:
int betAmount = 0;
Slider betSlider = new Slider();
betSlider.setMinorTickCount(4);
betSlider.setMajorTickUnit(250);
betSlider.setSnapToTicks(true);
betSlider.valueChangingProperty().addListener((obs, wasChanging, isChanging) -> {
if (!isChanging) {
betAmount = (int) betSlider.getValue();
update(); //update method, not relevant to problem
}
});
The problem that I am having is that the getValue()
method on my slider is being called before it snaps to the nearest tick. Because of this, I am getting the incorrect value stored in my betAmount
variable. I was wondering if there was any way to get the slider's value after it has finished snapping to the nearest tick.