gpt4 book ai didi

java - 在桌面应用程序中使用动画 GIF

转载 作者:行者123 更新时间:2023-12-03 01:26:39 25 4
gpt4 key购买 nike

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

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

最佳答案

new JLabel( new ImageIcon( URL ) );

EG

ShowAnimatedGif Star Zoom

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

关于java - 在桌面应用程序中使用动画 GIF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8958808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com