在applet中显示动画.gif的代码是什么?
答案 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);
}
}