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
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());
}
}
}