动画.GIF和Java

时间:2010-02-17 16:00:36

标签: java applet animated-gif

在applet中显示动画.gif的代码是什么?

1 个答案:

答案 0 :(得分:1)

只需使用ImageIcon并将其放入JLabel,例如

public class AnimatedGIF {

    public static void main(final String[] args) throws MalformedURLException {
        final URL location = new URL("http://upload.wikimedia.org/wikipedia/commons/archive/f/f0/20060824220301!Zipper_animated.gif");

        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new JLabel(new ImageIcon(location)));
        frame.pack();
        frame.setVisible(true);
    }

}