Swing is a large and complex part of the Java libraries. Perhaps not unexpectedly, it is also challenging to learn and use. It also has some bugs.
Useful tools from Sun include :
- the graphics repository of commonly used icons
- Java Web Start for deploying and updating applications over a network
- JavaHelp for creating HTML help systems
- the Look and Feel Design Guidelines (also discussed here)
- the Swing Tutorial
There is a widespread tendency for GUI code - in particular initialization code - to be implemented with very long methods. This is probably a bad idea, for the same reason that all excessively long methods are a bad idea - they are harder to understand and maintain.
Fields should be created only if necessary. If a particular element is created, wired into the GUI, and then no longer referenced anywhere else in the class, then it should probably not exist as a field, but rather as a simple local variable. This style will allow the more important GUI elements (fields) to stand out from the less important ones (local variables).
- follow the Look and Feel guidelines
- use a LayoutManager
- use Action objects
- create windows and dialogs with a uniform appearance