I am struggling with a bug in my application. The general idea was to multiply base price by slider argument, for example if the slider is set to 2, price = 2 * price
The problem is that is if I switch the slider again, math operations are accumulating. For example when I switched slider to 2, then to 3, after that to 4, my result is price * 2 * 3 * 4, but my expectation is to have price * 4 remembered. How can I fix it?
daysSlider.valueProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue arg0, Object arg1, Object arg2) {
int i = Integer.parseInt(priceTextField.getText());
priceTextField.textProperty().setValue(
String.valueOf((int) daysSlider.getValue()* i ));
}
});