Summary
Of all the libraries in Java, the GUI library has seen the most dramatic changes from Java 1.0 to Java 2. The Java 1.0 AWT was roundly criticized as being one of the worst designs seen, and while it would allow you to create portable programs, the resulting GUI was equally mediocre on all platforms. It was also limiting, awkward, and unpleasant to use compared with the native application development tools available on a particular platform.
When Java 1.1 introduced the new event model and JavaBeans, the stage was setnow it was possible to create GUI components that could be easily dragged and dropped inside visual application builder tools. In addition, the design of the event model and JavaBeans clearly shows strong consideration for ease of programming and maintainable code (something that was not evident in the 1.0 AWT). But it wasnt until the JFC/Swing classes appeared that the job was finished. With the Swing components, cross-platform GUI programming can be a civilized experience.
Actually, the only thing thats missing is the application builder tool, and this is where the real revolution lies. Microsofts Visual BASIC and Visual C++ require Microsofts application builder tools, as does Borlands Delphi and C++ Builder. If you want the application builder tool to get better, you have to cross your fingers and hope the vendor will give you what you want. But Java is an open environment, so not only does it allow for competing application builder environments, it encourages them. And for these tools to be taken seriously, they must support JavaBeans. This means a leveled playing field; if a better application builder tool comes along, youre not tied to the one youve been using. You can pick up and move to the new one and increase your productivity. This kind of competitive environment for GUI application builder tools has not been seen before, and the resulting marketplace can generate only positive results for the productivity of the programmer.
This chapter was meant only to give you an introduction to the power of Swing and to get you started so you could see how relatively simple it is to feel your way through the libraries. What youve seen so far will probably suffice for a good portion of your UI design needs. However, theres a lot more to Swing; its intended to be a fully powered UI design tool kit. Theres probably a way to accomplish just about everything you can imagine.
If you dont see what you need here, delve into the JDK documentation from Sun and search the Web, and if thats not enough, then find a dedicated Swing book. A good place to start is The JFC Swing Tutorial, by Walrath & Campione (Addison Wesley, 1999).