2

在小程序中显示动画 .gif 的代码是什么?

4

1 回答 1

1

只需使用 anImageIcon并将其放入 aJLabel中,例如

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

}
于 2011-08-25T11:23:50.980 回答