在桌面应用程序中使用动画GIF [英] Use animated GIF in desktop application
本文介绍了在桌面应用程序中使用动画GIF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道如何在我的程序中使用动画GIF(现在我只是使用PNG)。我只是希望能够循环浏览GIF中的不同图片,但我不知道要使用的类。
I was just wondering how to use animated GIFs in my program (right now I'm just using PNGs). I just want to be able to cycle through the different pictures in the GIFs, but I don't know the classes to use.
用于加载和显示的类动画GIF?
What classes are used to load and display animated GIFs?
推荐答案
new JLabel( new ImageIcon( URL ) );
EG
E.G.
import javax.swing.*;
import java.net.URL;
class ShowAnimatedGif {
public static void main(String[] args) throws Exception {
final URL url = new URL("http://pscode.org/media/starzoom-thumb.gif");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JLabel l = new JLabel(new ImageIcon(url));
JOptionPane.showMessageDialog(null, l);
}
});
}
}
这篇关于在桌面应用程序中使用动画GIF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文