Pessoal tenho o seguinte código para exibir uma tela inicial antes do meu programa, porém ele não está mostrando a imagem “SP2.gif” junto com a Splash Screen. O que posso fazer? Ele mostra a Splash vazia, só com meu nome, mas não a figura.
import java.awt.*;
import javax.swing.*;
public class SplashScreen extends JWindow {
private int duration;
public SplashScreen(int d) {
duration = d;
}
public void showSplash() {
JPanel content = (JPanel)getContentPane();
content.setBackground(Color.white);
// Configura a posição e o tamanho da janela
int width = 500;
int height =300;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
// Constrói o splash screen
JLabel label = new JLabel(new ImageIcon("imagens/SP2.gif"));
JLabel copyrt = new JLabel
("Copyright 2010, BY Cassiano Henrique", JLabel.CENTER);
copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
content.add(label, BorderLayout.CENTER);
content.add(copyrt, BorderLayout.SOUTH);
Color oraRed = new Color(156, 20, 20, 255);
content.setBorder(BorderFactory.createLineBorder(oraRed, 10));
// Torna visível
setVisible(true);
// Espera ate que os recursos estejam carregados
try { Thread.sleep(duration); } catch (Exception e) {}
setVisible(false);
}
public void showSplashAndExit() {
showSplash();
System.exit(0);
}
}