if (png.isAnimated()) {
panel.setPreferredSize(new Dimension(png.getWidth(), png.getHeight()));
final BufferedImage target =
panel.getGraphicsConfiguration().createCompatibleImage(png.getWidth(), png.getHeight(),
Transparency.TRANSLUCENT);
final Animator animator = new Animator(png, frames, target);
Timer timer = new Timer(50, null);
timer.setInitialDelay(0);
timer.addActionListener(animator);
timer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {