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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -