Creating new classes
In Forte for Java, Community Edition, you create new classes (as well as other objects) with templates. The template serves as a skeleton for the class and includes basic source code for that class. If you prefer to write all of the code yourself, you can choose the
Empty
template, and a file will be generated with the only code being the name of the package where you have created the template. A wide range of templates come with the IDE, and you can also create your own. For more on templates, see Using templates.Classes are created using the New From Template wizard. You can access this wizard from the Main Window, the Explorer, and the Object Browser. When you access the wizard from the Main Window, you select the type of object you want to create from the first page of the wizard, which also provides short descriptions of each template. When you access the wizard from a contextual menu in the Explorer or the Object Browser, you skip straight to the second page of the wizard. In addition, the package information is automatically entered for you, based on where you right-clicked.
To create an object through the Main Window:
- Choose New From Template... in one of the following ways:
- In the New From Template wizard that appears, expand the appropriate template category node (for example, Classes) and then select one of the templates. In the right panel of the dialog, a description of that template will appear.
![]()
Press Next to move to the Target Location page of the wizard.
- In the Name field, type the name you want to give the object. Do not type the extension for the file type. It will be added automatically.
- In the same page of the wizard, choose a package for the template. You can do this either by typing a package name in the Package field or by selecting one of the packages shown in the tree view just below it.
![]()
- Press Finish to exit the wizard. The object will then be created.
Note: The first time you create an object from template, you will be prompted whether or not you want to add the file to the current project.
If you select Yes, the new file will be visible under both the Filesystems and Project tabs of the Explorer and will be among the classes affected if you compile by project.
If you select No, the new file will not be visible under Project.
If you select Always, this new class and all subsequent classes created from the wizard will be added to the current project. If you select Never, classes will not be automatically added to the current project unless you are adding them to a directory that is already included in the project.
You can later add or remove files from projects and change whether files are automatically added to the current project. See Organizing work into projects for a complete description of project functionality.
To create an object from the Explorer:
- If the Explorer is not open, choose Open Explorer from the File menu or toolbar.
- Find the package (marked with a folder icon) under the Filesystems tab in the Explorer where you want to place the class and right-click on it to bring up its contextual menu.
- Choose New From Template, the template type from the first submenu, and then the template itself from the second submenu.
![]()
The Target Location page of the New From Template wizard will appear.
- Type the name of the object in the Name field, verify that the correct package is selected in the Package panel, and click Finish.
To create an object from the Object Browser:
- Open the Object Browser by selecting the Browsing tab in the Main Window to open up the Browsing workspace, or choose File | Object Browser from the main menu.
- In the Packages pane of the Object Browser, right-click on the package where you want to place the class and right-click on it to bring up its contextual menu.
- Choose New From Template, the template type from the first submenu, and then the template itself from the second submenu.
The Target Location page of the New From Template wizard will appear.
- Type the name of the object in the Name field, verify that the correct package is selected in the Package panel, and click Finish.
Once you have created the class, the Editor window (or a tab in the Editor window if the Editor is already open) will open up and display the skeleton code for that class already generated. If the class you have created from the template is a visual form, the Form window and Component Inspector will also open. The new class will also be automatically added to the Explorer's tree and the Object Browser (see Guide to the Object Browser).
You can now edit your new class, either directly in the Editor window (see "Editing Java sources" below) or by using customizer dialog boxes to have the dialog generate various class elements, such as methods, constructors, and variables.
Note: Unlike other IDEs, the "project" is not the central paradigm for developing applications in Forte for Java. All objects developed in the IDE as well as any other file systems mounted in the IDE are all accessible from the Object Browser or from the Filesystems tab in the Explorer. However, it is also possible to organize files into projects to make it more convenient to compile or run them and to store different Project Settings for various applications. See Organizing work into projects.
Contents | Prev | Next | Index |