This is a lot of work, and it scales poorly due to the cutting-and-pasting necessary for each AWT GUI component. Third party components must be subclassed too, which adds even more work. It will often be simpler to require a JDK 1.1 environment instead of trying to make this work under JDK 1.0.
The standard adapter classes provided by the JDK are simple, but do not provide the functionality required by even moderately sophisticated Java applications; they allow for too many silent failures, provide no help in keeping the GUI responsive, and do not allow an application's exception-handling policy to be easily changed.
In contrast, this article's sophisticated adapter classes, which address the shortcomings of the JDK 1.1's adapters, can help produce more robust and responsive applications. Nevertheless, the presented adapter classes are not the correct solution for all applications. Each application development team must decide whether these classes provide not enough functionality, enough, or too much. Someone still has to think.
Learn more about this topic
- Download the complete source code for this article in zip format
- Concurrent Programming in Java, Douglas Lea (Addison Wesley, 1996) -- provides a good discussion of multithreaded programming with Java. Before using the asynchronous adapter capability presented in this article, take the time to understand multithreaded programming as described here
- "Threads and Swing," Hans Muller and Kathy Walrath (The Swing Connection, April 1998) -- discusses why it is important that most operations on Swing GUI components take place on the AWT thread, and shows how to write code that does this