java - How to show a loading-animation in javafx-application? -


i try show loading-animation while access erp in code this:

protected void submit() {     messagefield.getstyleclass().add("smallloading");      submitimpl();     messagefield.getstyleclass().remove("smallloading"); } 

sadly animation never shown... result before. tried using platform.runlater, yielded same result. transfered last 2 lines in thread, worked (the animation shown), lead error "not on fx application thread", when submitter tried write message-field. when passed thread platform.runlater did not show animation... googled little bit, not find solution. maybe i'm missing important...

i appreciate help. thank you!

it seems don't understand how ui thread works.

the code you've posted single-threaded. operates on ui thread. add style class, work, remove it. problem sequence of operations "atomic": ui doesn't update until done. why don't see loading symbol change.

when put of within runlater result same. it's still on ui thread. difference here rather running code now, you're deferring until point "later" (probably soon).

when try put last 2 lines in separate thread, issue you're trying make ui changes on non-ui thread. that's not allowed.

what want run everything on non-ui thread, , push ui operations ui thread runlater. this:

new thread(() -> {     platform.runlater(()-> messagefield.getstyleclass().add("smallloading"));      submitimpl();      platform.runlater(()-> messagefield.getstyleclass().remove("smallloading")); }).start(); 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -