JavaFX preloader not updating progress

前端 未结 1 1154
情书的邮戳
情书的邮戳 2021-01-19 10:56

I\'m having trouble with the JavaFX Preloader. During the start phase the application will have to connect to a DB and read many so I thought it would be nice to display a s

相关标签:
1条回答
  • 2021-01-19 11:29

    I had same problem and I found solution after two hours of searching and 5 minutes of carefully reading of JavaDoc.:)

    Notifications send by notifyPreloader() method can be handled only by Preloader.handleApplicationNotification() method and it doesn't matter which type of notification are you sending.

    So change you code like this:

    public class PreloaderDemo extends Preloader {
    
       .... everything like it was and add this ...
    
       @Override
       public void handleApplicationNotification(PreloaderNotification arg0) {
              if (arg0 instanceof ProgressNotification) {
                 ProgressNotification pn= (ProgressNotification) arg0;
                 bar.setProgress(pn.getProgress());
                 System.out.println("Progress " + bar.getProgress());
              }
        }
    }
    
    0 讨论(0)
提交回复
热议问题