In Java 7, transparent GIF doesn't animate properly
So, I'm having an issue with a program. I have a GIF that's transparent.
The animation works properly, except that instead of showing one image at
a time, it sort of stacks the images on top of each other. I tried
overriding the paintIcon method of the ImageIcon class to clear the
canvas, but that didn't work either. ANy thoughts? My code:
public class GifRunner extends JPanel {
JLabel label;
public GifRunner() {
super();
label = new JLabel();
ImageIcon icon = new
ImageIcon(getClass().getResource("/animation.gif");
label.setIcon(icon);
add(label);
}
public static void main(String[] args) {
JFrame frame = new JFrame("");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GifRunner panel = new GifRunner();
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
}
Any help would be much appreciated
No comments:
Post a Comment