Displaying animated GIFs in a JList

Try this example with the following two images:

import javax.swing.border.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.*;
import java.awt.*;
 
public class Main {
   public static void main(String args[]) {
      JFrame frame = new JFrame("JList Background Demonstration");
 
      JList list = new JList();
 
      String [] imageIcon = new String[] {
         "female.gif", "male.gif"
      };
 
      // create model
      Vector v = new Vector();
      for (int i=0; i<10; i++) {
         ImageIcon ii = new ImageIcon(imageIcon[i % 2]);
         ii.setImageObserver(new AnimatedObserver(list, i));
         v.addElement(ii);
      }
 
      list.setListData(v);
  
      frame.getContentPane().add(BorderLayout.CENTER, list); //new JScrollPane(list));
      frame.setDefaultCloseOperation(3);
      frame.pack();
      frame.setVisible(true);
   }
}
 
class AnimatedObserver implements ImageObserver 
{ 
   JList list; 
   int index; 
 
   public AnimatedObserver(JList list, int index) { 
      this.list = list; 
      this.index = index; 
   }  
 
   public boolean imageUpdate (Image img, int infoflags, int x, int y, int width, int height) {
      if ((infoflags & (FRAMEBITS|ALLBITS)) != 0) { 
         Rectangle rect = list.getCellBounds(index, index); 
         list.repaint(rect); 
      } 
 
      return (infoflags & (ALLBITS|ABORT)) == 0; 
   }
}