Dementor Dementor - 1 year ago 131
Java Question

Java SplashScreen transparent image

I have an application that takes 6 seconds to start, and I want to add a splash screen.
I have this code:

public class SplashScreen extends JWindow {
private static final long serialVersionUID = 1L;

Image bi;
ImageIcon ii;

boolean loaded = false;

public SplashScreen(String path) {
try {
bi = Toolkit.getDefaultToolkit().getImage(path);
ii = new ImageIcon(bi);
setSize(ii.getIconWidth(), ii.getIconHeight());
loaded = true;
} catch (Exception exception) {

public void showSplashScreen(boolean flag) {
if (!loaded) {
System.err.println("Splash screen image isn't loaded.");

public void dispose() {

public void paint(Graphics g) {
g.drawImage(bi, 0, 0, null);

The picture looks fine, but I want it to look transparent, and I can not get it.

Answer Source

I solved my problem, i added this line:

setBackground(new Color(0, 255, 0, 0));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download