Swing components follow a standard set of conventions, similar to JavaBeans. As a result, components can report their public variables includes, and they provide methods for accessing and setting values that follow a presecribed naming convention. Consequently, powerful programming tools can be developed that allow the user to build the user interface through drag and drop actions and to visually interconnect components through auto-generated events and event listener mechanisms.
The discussion here is based on a simple applet that includes two buttons and two textfields. One button copies the text entered into one textfield into the second; the other button clears both textfields. (This is the same program assigned as the first Java exercise.)
AWT version
This code shows a solution implemented using the AWT.
Swing (1.2.2) version
This code is hand written and closely matches the AWT version
Swing version, auto-generated
This code was generated entirely by VisualCafeDBE as a result of drag and drop and visual event linking facilites.