NetBeans IDE dynamically generates the code for GUI construction. You can view this code in the Source view of the Form Editor (click the Source button in the Form Editor's toolbar). In addition to the code generated within the class in its class-name. java file, the IDE maintains an XML file called class-name.from that details the structure of the form. Note that the source-code control systems (such as CVS) supported by NetBeans ensure by default that the .form file is maintained in the repository in addition to the .java file. The generated code within the .java source file is delimited by special comments (for example, //GEN-BEGIN:initComponents ...//GEN-END:initComponents). The editor does not allow this code to be modified and indicates the unmodifiable code with a pale blue background. Although you could modify this code outside the IDE, it is not recommended, because those modifications would be lost if you reopened the form in the IDE. (The IDE regenerates the .java file of a form created in the IDE from the .form files each time you open the file in the IDE.) The use of delimited generated code prompted vigorous discussion in the NetBeans IDE team, but the advantages are significant: It is extremely difficult to reliably "reverse-engineer" arbitrary Swing code without requiring restrictive coding discipline on the developer's part. Instead, NetBeans IDE provides "hooks" where you can add (almost) any arbitrary code to be part of the code to be generated. This code is added via a codeaware window accessed from the Code tab of the Properties window for the component. The properties used are:
In addition, the initial values of the various properties of components can be specified in various ways:
|