java - JavaFX Loading in Background -
this question has answer here:
how have dialog
has indeterminate progressindicator
in foreground while main thread loads bunch of data in background , loads on main scene
. currently, when program loads, page is white, unresponsive, , looks bad. also, best way or there better way.
your window frozen/unresponsive because loading data in main thread (which thread used javafx render window).
what need perform loading in separate thread, run parallel main thread. when loading complete, thread notify main thread , pass loaded data render.
here quick way create new thread loads data:
thread mythread = new thread(new runnable() { @override public void run() { // perform loading here // once loading complete, notify main thread } }); mythread.start();
if use this, indeterminate progressindicator
not affected.
there many ways "notify main thread". perhaps pass instance of main class secondary thread, , when data done loading call method on instance.
Comments
Post a Comment