Question

I need to do a loading window in java like this:

Splash

I tried with the jframe but I can't figure it out, I can't remove the close button, my jframe should look like a jpanel before that program begin, somebody know how to do this.

Was it helpful?

Solution

You Could...

Use Java's inbuild splash screen support. This is good as it gets loaded relatively earlier in the process by the JVM itself, so it comes up reasonably quick.

The major drawback (in my opinion) is it can be troublesome to get right as it doesn't follow the standard painting process that most developers are use to and you are going to have to paint it all yourself, there's no component support

You Could...

Create a JWindow. This is a frameless window, which won't appear on the taskbar (at least for some OSs).

You gain complete control over what and how things get displayed, as it's like dealing with any other window.

The only problem is that it won't become available for you to load until the JVM has completed loading your application. If the JVM needs to download resources over the network, for example, this could produce an undesirable delay

For example

You Could...

Use an undecorated frame. This is pretty much the same as the JWindow option, except that a taskbar icon will be displayed, but on some OSs, this can't be completely helped.

See Frame#setUndecorated for more details

Final thoughts

Swing is not thread safe. So if you're displaying a splash screen, this means you should be ensuring that whatever actions you are taking are done off the Event Dispatching Thread, possibly through the use of SwingWorker

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top