简体   繁体   English

JavaFX:在应用程序之前不会显示预加载器

[英]JavaFX: Preloader doesn't show up before Application

Tutorial I'm following: http://acodigo.blogspot.com/2016/03/javafx-preloader-pantalla-de-carga.html 我正在关注的教程: http : //acodigo.blogspot.com/2016/03/javafx-preloader-pantalla-de-carga.html

My preloader doesn't show up before my application when I hit run inside of Eclipse, or when I click on my runnable jar I exported. 当我在Eclipse中运行run或单击导出的可运行jar时,预加载器不会在应用程序之前显示。

Gist: https://gist.github.com/htha9587/d42badd8ff2df0cc1632dbbc19e1ee5e 要点: https : //gist.github.com/htha9587/d42badd8ff2df0cc1632dbbc19e1ee5e

Could this be one way to make it show up?: I could try adding this method to MainLoader.java: 这可能是使其显示出来的一种方法吗?:我可以尝试将此方法添加到MainLoader.java中:

@Override public void init () throws Exception 
{
    Thread . Sleep (2500); 
}

Any reason why this is happening, and how I can solve It? 发生这种情况的任何原因以及如何解决?

Hello I looked over your question if I understand correctly you would like to see the your Preloader screen. 您好,我查看了您的问题,如果我理解正确,那么您希望看到“预加载器”屏幕。

Your thread.sleep() command causes the Preloader also to sleep. 您的thread.sleep()命令使Preloader也进入睡眠状态。 If you like to see it you need to add another intensive task like 如果您想看到它,则需要添加另一个密集任务,例如

@Override public void init () throws Exception{
    int COUNT_LIMIT = 40000;
    for (int i = 0; i < COUNT_LIMIT; i++) {
        double progress = (100 * i) / COUNT_LIMIT;
        LauncherImpl.notifyPreloader(this, new Preloader.ProgressNotification(progress));
    }
}

This should do the trick maybe increase COUNT_LIMIT to something that is even higher - maybe (10^10) . 这应该可以解决问题,也许可以将COUNT_LIMIT增加到甚至更高-也许(10^10)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM