【问题标题】:Use animated GIF in desktop application在桌面应用程序中使用动画 GIF
【发布时间】:2012-02-16 01:05:29
【问题描述】:

我只是想知道如何在我的程序中使用动画 GIF(现在我只使用 PNG)。我只是希望能够循环浏览 GIF 中的不同图片,但我不知道要使用的类。

哪些类用于加载和显示动画 GIF?

【问题讨论】:

    标签: java image swing gif


    【解决方案1】:
    new JLabel( new ImageIcon( URL ) );
    

    例如

    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);
                }
            });
        }
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 2014-08-26
    • 2012-07-30
    • 2013-11-26
    • 2015-09-24
    相关资源
    最近更新 更多