Java Code Generator

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)

Note: If you use the runtime library, you can disable the code generator in the Java Code Generator preferences.

Generation of nested classes

The Java code generator is able to generate and update nested classes. You can specify a class name for each component in your form. This allows you to organize your source code in an object-oriented way.

Java 8 support

Use lambda expressions in generated source code to invoke event handlers if source compatibility is set to Java 8.

Java 8:

browseButton.addActionListener(e -> browseButtonActionPerformed(e));

Java 7 and earlier:

browseButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        browseButtonActionPerformed(e);
    }
});

Generate Eclipse, IntelliJ IDEA or NetBeans non-nls tags

The Java code generator can write Eclipse non-nls tags (//$NON-NLS-n$), IntelliJ IDEA non-nls tags (//NON-NLS) and NetBeans no-i18n tags (//NOI18N). Enable it in the Java Code Generator preferences.

Code formatter

The Java code generator can now use the Eclipse code formatter to format generated code. Enable option "Use Eclipse code formatter" in Java Code Generator preferences.

(Eclipse plug-in only)

Custom Create property

Better support for custom creation of components (e.g. using factories) with new property Custom Create (category Code Generation). When checked for a component, the JFormDesigner generates an empty method createUIComponents() where you can write your own component creation code.

Code templates

When generating new Java files, nested classes or event handlers, JFormDesigner uses code templates specified in the Templates preferences.