Sunday, May 20, 2007

Fixing "hanging" user interface and providing better submission progress

Recently I have been revamping the graphical user interface for LastPod.

One of my favorite new features are the progress indication components. LastPod used to provide no progress indication when submitting tracks. Actually, the user interface used to "hang" while the submission was occurring. I reworked the Submit button using Swingworker, which allows the submission to occur in a background thread, thus freeing the user interface from hanging. I used the "swingworker 3" implementation, which is compatible with JDK 1.4 or greater. I had a fairly hard time finding useful information on this implementation because it is getting fairly old. There is also a wealth of information about the latest SwingWorker, in Java 6, which is quite different from "swingworker 3".

After fixing the hanging, I realized LastPod needed progress indication. To solve this problem, I added a progress bar and a throbber. The progress bar (JProgressBar) updates as tracks are submitted. The throbber uses a Timer to repaint, therefore the animation is smooth. Both the progress bar and the throbber are updated from within the swing worker thread, otherwise submission would complete before the interface would ever refresh, which defeats the entire purpose of the progress indicator.

Please submit any feature or bug requests that you find.

No comments: