Documentation
Java Code Generator
JFormDesigner can generate and update Java source code. It uses the same name for the Java file as for the Form file. E.g.:
C:\MyProject\src\com\myproject\WelcomeDialog.jfd
(form
file)
C:\MyProject\src\com\myproject\WelcomeDialog.java
(java file)
Stand-alone: Before creating new forms, you should
specify the locations of your Java
source folders in the
Project dialog. Then JFormDesigner can generate valid
package
statements. For the above example, you should add C:\MyProject\src
.
IDE plug-ins: The source folders of the IDE projects are used.
If the Java file does not exist, JFormDesigner generates a new one. Otherwise, it parses the existing Java file and inserts/updates the code for the form and adds import statements if necessary.
Stand-alone: The Java file will be updated when saving the form file.
IDE plug-ins: If the Java file is opened in the IDE editor, it will be immediately updated in-memory on each change in JFormDesigner. Otherwise, it will be updated when saving the form file.
JFormDesigner uses special comments to identify the code sections that it will generate/update. E.g.:
// JFormDesigner - ... //GEN-BEGIN:initComponents // JFormDesigner - ... //GEN-END:initComponents
The starting comment must contain GEN-BEGIN:<keyword>
, the ending comment
GEN-END:<keyword>
. These comments are NetBeans compatible. The text before
GEN-BEGIN
and GEN-END
(in the same line) does not matter. JFormDesigner uses
the following keywords:
Keyword name | Description |
---|---|
initComponents | Used for code that instantiates and initializes the components of the form. |
variables | Used for code that declares the class level variables for components. |
initI18n | Used for code that initializes localized component properties if option "Generate initComponentsI18n() method" is enabled in the Localization (Java Code Generator) preferences or "(form)" properties. |
initBindings | Used for code that initializes bindings if option "Generate initComponentBindings() method" is enabled in the Localization (Java Code Generator) preferences or "(form)" properties. |