IntelliJ IDEA 2024.1 Help

Creating and Opening Forms

GUI Designer equips the developers with the possibility to create GUI forms with the desired layout and bound class, and dialogs. A form can be created as only a form file, or together with a UI class. A dialog framework consists of a class defining basic components and methods, and a GUI form with components bound to the fields of the UI class.

Prior to creating GUI forms and dialogs, select a package where the forms will be stored. You might need to create a package first. It is recommended to store the forms and dialogs in the same package as the classes that implement their functionality.

Creating a New GUI Form or Dialog

To create a new GUI form

  1. In the main menu, go to File | New.

  2. On the pop-up menu, choose GUI Form.

  3. Specify the name of the new form, and select the layout manager.

  4. Check the option Create bound class, and specify the bound class name.

  5. Click OK.

To create a new dialog

  1. In the main menu, go to File | New.

  2. On the pop-up menu, choose Dialog.

  3. Specify the name of the new dialog.

  4. Specify the following options:

    • Generate main() method that creates and shows dialog.

    • Generate OK handler.

    • Generate Cancel handler.

  5. Click OK.

Creating a form from a File Template

You can save any form as a File Template, and thus preserve commonly needed dialogs or panes of controls for later reuse. For more information about creating and using File Templates, refer to the sections:

To create a File Template from a GUI form

  1. Create a GUI form or open it in the GUI Designer.

  2. From the Main menu, choose File | Save File as Template. The File Templates dialog displays the source code of the form. The extension of the new template is .form

  3. Specify the template name, and click OK.

To create a new GUI form from a File Template

  1. In the Project tool window, right-click the package where you want to create the new form.

  2. On the context menu choose New. The submenu contains items for all defined File Templates, including GUI forms.

  3. Select the desired GUI form template on the context menu, and give it a name when prompted.

Opening Existing GUI Forms

Open form files the same way you open source code or text files for editing. Locate the file in the appropriate navigation view, select it, and do one of the following:

  • Double-click.

  • Choose Jump to Source on the context menu.

  • Press F4.

Each form opens in a separate tab in the same space occupied by the Editor for source code files. You can have source code/text files and form files open simultaneously.

Last modified: 11 February 2024