I'm having trouble getting the JavaFX UI to keep me working while doing a background function. I have set this very simple code -
@fxml progress prgb progress; @fxml Private Wide Onclic (Action Event Event) {Task and Left; Wide & gt; T = new task & lt; Zero & gt; () {@Override Safe Voice Call ()) throws an exception {for (int i = 0; i <10; i ++) {updateProgress (i, 9); Thread.Sleep (1000); } Return tap; }}; . PrgbProgress.progressProperty () tie (t.progressProperty ()); New thread (t) .on (); }
What I hope to happen is that the progress bar is updated every ~ 1 second until the work is completed. Instead, the UI completely freezes for 10 seconds, after which the progress bar is complete. Just to clarify it - the problem is not only that all updates appear at the end once, but also that the UI is not completely unresponsive.
I have read about any other question about this topic, but no answer can be found, what am I doing?
Thank you.
Use Start () instead of Run < / Em>
@fxl progress progress prgb progress; @fxml Private Wide Onclic (Action Event Event) {Task and Left; Wide & gt; T = new task & lt; Zero & gt; () {@Override Safe Voice Call ()) throws an exception {for (int i = 0; i <10; i ++) {updateProgress (i, 9); Thread.Sleep (1000); } Return tap; }}; . PrgbProgress.progressProperty () tie (t.progressProperty ()); // new thread (t) .Run (); // Wrong new thread (t). Start (); // true}
Comments
Post a Comment