java - Javafx Slider event listener being called before it snaps to the nearest tick -
i trying update information every time slider
value changed, have code set 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 problem } });
the problem having getvalue()
method on slider being called before snaps nearest tick. because of this, getting incorrect value stored in betamount
variable. wondering if there way slider's value after has finished snapping nearest tick.
try using valueproperty()
in place of valuechangingproperty()
betslider.valueproperty().addlistener((obs, waschanging, ischanging) -> { betamount = newvalue.intvalue()); });
valuechanging
-> provides notification value changing.
value
-> current value represented slider.
Comments
Post a Comment