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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -