How do I use SplashScreen without throwing a NullPointerException?

99封情书 提交于 2019-11-29 18:29:41

Take a look at How to Create a Splash Screen

You either need supply the image via the command line or the Jar manifest

Update with some basics

You must supply an image for the splash screen to. If you don't, it will always be null.

There are two ways to do this

1. From the command line

java -splash:path/to/image.jpg {other command line options}

The image must reside within the context of the class loader for the application (such as an embedded resource).

2. The Manifest file

This is a little more difficult, but will result in a much simpler execution (as no one needs to remember to add the command line ;))...

Check out Working with Manifest Files for more details.

How you create it depends on your environment.

For example, in Netbeans, you can set the splash screen property in the project properties dialog, under the Application node.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!