IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

Creating Form Initialization Code

Last modified: 10 August 2022

When you finish building a GUI Designer form, at a minimum you should have a class that is bound to the form, and component type fields in the class bound to the various form components.

If the binary class files are specified as the output option, all runtime initialization code is generated in the class file. If your form has a bound class, you will not see the automatically generated initialization code there. In case you have selected Java source code as the output option, the bound class of your form will contain automatically generated $$$setupUI$$$() method.

Sometimes you might need to provide initialization code of your own. For example, you want a GUI component to be instantiated by a non-default constructor with certain parameters. In this case, IntelliJ IDEA will not generate instantiation of the component, and it is your responsibility to provide the call to constructor in the createUIComponents() method. Otherwise, a Null Pointer Exception will be reported. Follow the general technique described below.