Generating source code

The class SomeClass

The code GridBagger generates is based on a hypothetical class with the name SomeComponent. Below is a simple example of the source generated for a layout with two components.

From this example it can be seen that the code creates instances of SomeComponent with the allocated text caption. Only one instance of GridBagConstraints is used for efficiency. Only constraints that change are set before the component is added to the layout. The programmer must obviously substitute in the instances of actual components such as Button or JPanel which are to be actually used in the layout.

Saving the source

The buttons at the top of the source dialog allow the generated code to be either specified to a user specified file or to be copied into the system clipboard.