最近编写项目,用到一个Splash Screen。
现奉献给大家。
import java.awt.Dimension;
import java.awt.Toolkit;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class SplashScreen extends JFrame {
/**Date 08.17.2005
*
* Splash Screen
* Very Simple
* @author Pudgy
* @version 0.01
*
*
*/
private static final long serialVersionUID = 5124L;
public SplashScreen() {
super("Starting jDicomSee");
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
URL imageURL = searchFile("splash.png");
if (imageURL != null) {
getContentPane().add(new JLabel(new ImageIcon(imageURL)));
}
setUndecorated(true);
pack();
setLocation((screenSize.width - getWidth()) / 2,
(screenSize.height - getHeight()) / 2);
setVisible(true);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private URL searchFile(String fileName) {
URL url = getClass().getClassLoader().getResource(fileName);
if (url == null)
url = getClass().getClassLoader().getResource("images/" + fileName);
return url;
}
}
posted on 2005-08-22 21:29
Pudgy's World 阅读(1017)
评论(2) 编辑 收藏 所属分类:
Java Newbie