Creating a New Form

See Also

In the IDE, you can create JFC/Swing or AWT (Abstract Window Toolkit) forms, pre-built sample application skeletons, or any class that is based on the JavaBeans component architecture using the provided templates.

You can create forms within an existing project or you can create a new project that is based on the Swing Application Framework and that already contains a skeleton form.

To create a new project that contains a skeleton form:

  1. Choose File > New Project from the main menu.
  2. Select the Java node in the Categories pane and select the Java Desktop Application template. Click Next.
  3. Enter a name and location for the project.
  4. Select an application shell.

    The Basic Application shell provides a skeleton application based on the Swing Application Framework.

    The Database Application shell enables you to quickly generate an interface for a simple CRUD (create, read, update, delete) application that is based on a single database table. It implements a JTable component for viewing contents of the database table; text fields for entering data; and buttons for saving records, adding new records, and so on.

  5. If you have selected the Basic Application shell, click Finish.
  6. If you have selected the Database Application shell, use the next two pages of wizard to specify a database table and to specify the columns to represent in the master/detail view.
  7. The IDE creates a project with a skeleton form of the selected type and opens the form in the Design view of the Source Editor.

To create a new GUI form in an existing project:

  1. Choose File > New File from the main menu.
  2. In the New wizard's Project combo box, select the project for which you want to create the form.
  3. Expand the Java GUI Forms node in the Categories pane and select the desired form template. Click Next.
  4. Enter the GUI form's class name and location. Click Finish.
  5. The IDE creates a blank form of the selected type and opens and opens the form in the Design view of the Source Editor.

GUI Form Types in the New File Wizard:

The following table lists the types of form templates available in the IDE. Each differs in the design time and run time look of the form as well as in the code generated for the form's class.

Form Type Description
JApplet Program run by a Java-enabled web browser or other applet viewer.
JDialog Modal or modeless window for collecting user input.
JFrame Top-level application window.
JInternalFrame An internal frame that can be placed on a JDesktopPane component to create an MDI application.
JPanel Lightweight container for holding parts of an interface. In turn, the container can be used in any other container, such as a JFrame, JPanel, JApplet, or JDialog component.
Bean Form

The template used to create a new form based on any JavaBeans component. The new form can be visual or nonvisual. Specify the class in the Superclass field on the Form Superclass page of the New wizard. The bean class that you specify when creating the new form must be in the classpath and must be already compiled.

A bean is any class that complies with the JavaBeans component architecture. A bean must have a public constructor without parameters. Use any JFC/Swing component as an example of a JavaBeans class. For example, you can use javax.swing.JButton to create a form that will produce a customized button.

Using this template, you can also create a plain container for holding beans by specifying java.lang.Object as the superclass.

AWT Forms Visual forms that are based on the AWT. The AWT forms include Applet, Dialog, Frame, and Panel.
Sample Forms Customized sample forms that include a JFrame-based application with three menus, a JFrame application that can be used as the main window for an MDI application, and a dialog box with OK and Cancel buttons.
See Also
Working with Containers
About Layout Managers
Creating a Multiple Document Interface (MDI) Application
About the Swing Application Framework

Legal Notices