In the last week or so, while working on some Java Swing code for a project at work, I hit Swing bug #4480705. When the user clicked a button to start an "activation", I changed the ImageIcon on a JButton to an animated GIF to indicate activity (e.g., "we're doing something, please wait"). So, while the application was busy, I disabled the JButton and set its ImageIcon to an animated spinner. Loading this animated GIF and setting it on the JButton using setIcon() caused the Java Swing EventQueue threads to deadlock, as described here, and my entire application hung. Well technically speaking, not the entire application, but just the Swing portion of the JVM. Clearly, Swing doesn't like animated GIF's as much as the Sun documentation claims.
The solution to this deadlock is to avoid using animated GIF's all together, and write your own animate loop using javax.swing.Timer. That's exactly what I did, and it works great.
For your viewing pleasure, I wrote up a quick demo/example (see Beavis and Butthead screencap) which demonstrates the use of javax.swing.Timer and how you can integrate it into your Swing application.
Download just the source, or the full Eclipse project.
Rock on.
