Just use a ImageIcon for this task, it automatically animates gifs. The code below produced this screenshot (the ajax-loader.gif
was downloaded from http://www.ajaxload.info/):

Code:
public static void main(String[] args) throws Exception {
JFrame frame = new JFrame("Test");
ImageIcon loading = new ImageIcon("ajax-loader.gif");
frame.add(new JLabel("loading... ", loading, JLabel.CENTER));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
}