图像作为JavaFX应用程序的启动画面不会自动隐藏 [英] Image as splashscreen for JavaFX application not hiding automatically

查看:155
本文介绍了图像作为JavaFX应用程序的启动画面不会自动隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的.png图像文件,希望在JavaFX应用程序加载时显示.

I have a simple .png image file that I wish to show while the JavaFX application is loading.

我正在使用NetBeans作为我的IDE,并且我知道可以像这样添加启动屏幕: 项目属性->运行-> VM选项:-splash:图像路径

I am using NetBeans as my IDE and I know that splashscreen can be added like so: Project properties -> Run -> VM Options: -splash:path-to-image

现在,启动画面可以很好地启动,但是在我的应用程序启动后它不会关闭.一直坐在屏幕上,直到我完全关闭我的应用程序为止. 如文档所述( http://docs.oracle. com/javase/7/docs/api/java/awt/SplashScreen.html )初始屏幕窗口在Swing/AWT显示第一个窗口后即自动关闭". JavaFX既不是Swing也不是AWT应用程序.那么如何关闭它?

Now the splashscreen starts nicely, but it won't close after my application has started. Just sits there on the screen until I close my application completely. As the documentation says (http://docs.oracle.com/javase/7/docs/api/java/awt/SplashScreen.html) "The splash screen window is closed automatically as soon as the first window is displayed by Swing/AWT". JavaFX is not Swing nor AWT application. So how can I close it?

感谢您的帮助!

推荐答案

好,回答我自己的问题.

Ok, answering my own question.

在VM选项中设置了启动时:-splash:映像路径. 在JavaFX中,我可以这样关闭它:

When splash is set in VM Options: -splash:path-to-image. The in JavaFX I was able to close it like this:

//Get the splashscreen
final SplashScreen splash = SplashScreen.getSplashScreen();

//Close splashscreen
    if (splash != null) {
        System.out.println("Closing splashscreen...");
        splash.close();
    }

希望这对其他人也有所帮助! ;)

Hope this is somewhat helpful to others also! ;)

这篇关于图像作为JavaFX应用程序的启动画面不会自动隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆