Swing in general

Swing is a large and complex part of the Java libraries. Perhaps not unexpectedly, it's also challenging to learn and use. It also has some bugs.

Useful tools from Sun include:

Long methods

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.

Unnecessary Fields

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).

Good habits

Oracle has stated that it will be focusing its efforts on JavaFX, and not Swing. Since JavaFX is the more modern tool, you may want to seriously consider basing your app on JavaFX instead. Note as well that existing Swing apps can be transitioned gradually over to JavaFX.
See Also :
Look and Feel guidelines
Standardized dialogs
Would you use this technique?
Yes   No   Undecided   
© 2014 Hirondelle Systems | Source Code | Contact | License | RSS
Individual code snippets can be used under this BSD license - Last updated on September 21, 2013.
Over 2,000,000 unique IPs last year - Built with WEB4J.
- In Memoriam : Bill Dirani -