Swing Splashscreen
Hi,
I am a Java/Swing newbie, trying to convert from C++. I am writing a small app to interface with a PostgreSQL DB. I would like to include a splashscreen, and have used the code on sun's website (see below). I call this from the main().
The splashscreen loads however it is simply a grey box. I have no idea what is wrong with it? Anybody have any suggestions, much appreciated. Thanks!
////////////////////////////////////////// SPLASH SCREEN////////////////////////////////////////////
public class SplashScreen extends JWindow {
private int duration;
public SplashScreen(int d) {
duration = d;
}
// A simple little method to show a title screen in the center
// of the screen for the amount of time given in the constructor
public void showSplash() {
JPanel content = (JPanel)getContentPane();
content.setBackground(Color.BLUE);
// Set the window's bounds, centering the window
int width = 450;
int height =315;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
// Build the splash screen
JLabel label = new JLabel(new ImageIcon("/home/ehellaby/lehman.jpg"));
JLabel copyrt = new JLabel
("Lehman Brothers. Developed by Edward Hellaby", 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));
// Display it
setVisible(true);
// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); } catch (Exception e) {}
setVisible(false);
}
public void showSplashAndExit() {
showSplash();
System.exit(0);
}
}

