我正在使用 java 1.5 并希望在启动我的应用程序之前显示一个动画并在我的应用程序加载时关闭它。我在谷歌搜索后创建了一些东西,但如果我使用不显示的动画 gif,动画 gif 不会动画。
有没有人有什么问题并知道该怎么做?
public class SplashFrameSwing extends JFrame{
JPanel contentPane;
JLabel imageLabel = new JLabel();
public SplashFrameSwing(String url) throws IOException {
try {
ImageIcon ii = new ImageIcon(url);
setBackground(new Color(0, 0, 0, 0));
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
contentPane = (JPanel) getContentPane();
contentPane.setLayout(new BorderLayout());
setUndecorated(true);
setSize(new Dimension(ii.getIconWidth(),ii.getIconHeight()));
imageLabel.setIcon(ii);
contentPane.add(imageLabel, java.awt.BorderLayout.CENTER);
this.setLocationRelativeTo(null);
this.setVisible(true);
} catch (Exception exception) {
exception.printStackTrace();
}
}
public static void main(String... args){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
// URL url = new URL("http://i34.photobucket.com/albums/d129/nirendaran/Speed/verify_anim.gif");
String url = "C:\\Users\\TV\\Pictures\\Icon\\sniffer-prev.gif";
SplashFrameSwing splash = new SplashFrameSwing(url);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}