Why do I lose my visual composition when I export my source code?

Christian Damus

The Visual Composition information is stored, in the repository, separately from the Java code which is generated from it. If you simply export the source or bytcodes of a visually-composed class (to a .java/.class file or to a JAR) the visual design information is not exported.

The best way to exchange visually composed classes in VAJ is via the repository format (.dat files). Currently, only projects or packages can be exported to .dat, so you may have to export some extra baggage along with your class. Note that you can only export versioned projects or packages to a .dat file; you need to version your project or package before exporting it.

VAJ can encode the visual composition data in a special method called getMetaData() in your class. To enable this behaviour in VAJ 3.x, select the Window->Options... menu, select Visual Composition->Code generation in the tree, and check the Generate meta data method option (a similar option exists in VAJ2.0).

After checking this option, any classes you save in the Visual Composition Editor will now contain a method called getBuilderData(), which encodes the visual design in a comment at the top of the method.
Note: Any classes that you had visually designed before enabling this option will not have the getBuilderData() method. You will then have to open the VCE on these classes and regenerate them (using the Bean->Regenerate menu option) to actually create the getBuilderData() method.

Even though this meta-data metod feature may help, exporting/importing using repository files is the preferred way to transfer packages/Projects between instances of VAJ.