Show animated GIF
Solution 1:
Using Swing you could simply use a JLabel
:
public static void main(String[] args) throws MalformedURLException {
URL url = new URL("<url_to_animated_gif>");
Icon icon = new ImageIcon(url);
JLabel label = new JLabel(icon);
JFrame f = new JFrame("Animation");
f.getContentPane().add(label);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
Solution 2:
check it out:
http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#getresource
Solution 3:
For loading animated gifs stored in a source package (in the source code), this worked for me:
URL url = MyClass.class.getResource("/res/images/animated.gif");
ImageIcon imageIcon = new ImageIcon(url);
JLabel label = new JLabel(imageIcon);