user interface - Javafx concurrency and gui-update -
what i'm trying following: want fade in overlay screen before doing background work , fade overlay screen out when task finishes.
anyhow, java performs background task requestservice.dorequest
, afterwards fades screen in , out. current order like:
- task
- fade in
- fade out
while should be:
- fade in
- task
- fade out
i think tried every possible configuration of threads, tasks, service, etc..
so how 1 correctly update gui try achieve?
controller.java:
public void dorequest(request r) { task<float> t = new task<float>() { @override protected float call() throws exception { try { updateprogress(.5f, 1); requestservice.dorequest(r); } catch(exception e) { badge.setvisible(true); badge.settext(e.getmessage()); } { updateprogress(0f, 1); } return null; } }; overlay.opacityproperty().bind(t.progressproperty()); overlay.opacityproperty().addlistener((obs, o, n) -> system.out.println(n)); t.run(); }
btw: if watch update of overlays opacityproperty, 1 can see property gets updated in right order, gui refresh seems hang.
Comments
Post a Comment