希望大家可以帮我看看这个程序
请问以下这个程序图片为什么出不来,没有报任何错。就是图片出不来。
import javax.swing.*;
import java.awt.*;
import java.net.*;
public class JSplashWindow extends JWindow implements Runnable {
Thread splashThread=null;
boolean bool = true;
JPanel splash = null;
URL url = null;
public JSplashWindow() {
splash = new JPanel(new BorderLayout());
url = getClass().getResource("/images/winter.jpg");
setContentPane(splash);
Dimension screen = getToolkit().getScreenSize();
pack();
setLocation((screen.width - getSize().width) / 2,(screen.height - getSize().height) / 2);
}
public void start(){
this.toFront();
splashThread=new Thread(this);
splashThread.start();
}
public void run(){
JLabel label = new JLabel(new ImageIcon(url));
try {
setVisible(true);
while(bool) {
if(url != null){
splash.add(label,BorderLayout.CENTER);
}
Thread.sleep(500);
splash.remove(label);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Thread.sleep(500);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
static void showFrame(String title){
JFrame frame = new JFrame(title);
frame.setSize(400,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
public static void main(String[] args) {
showFrame("Demo splash window");
JSplashWindow splash = new JSplashWindow();
splash.start();
}
}