Designing Forms

   

A form is a graphical representation of a window. Forms can be used to create standard windows, Multiple Document Interface (MDI) windows, dialog boxes, or display surfaces for graphical routines. As with all objects in Java, forms are also classes. To define the user interface for a form, you place controls on its surface. Each form and control contains properties and events that define behavior, appearance, and functionality.

In order for a form and its controls to be displayed properly, you typically add an extensive amount of code to the form's class. To make this task easier, you can use the Forms Designer. The Forms Designer is a graphical tool for defining forms for your applications. You can visually add controls to a form, set the properties for the form and its controls, and create event handlers for the events that you want to respond to.

The Forms Designer contains the following components:

  • . Displays all the controls currently available in your application. You can drag controls from the Toolbox onto the form's design surface.

  • . Displays properties and events that are available for the currently selected form or control. Properties define the appearance and behavior of a form or control. Events are notifications of an action in a control or form. You can use the Properties window to change properties and create event handlers for a form or control.

  • Design surface. The graphical representation of the form as it will be shown at run time. Controls are placed on the design surface to define the user interface. The design surface also has layout and alignment tools so that controls on the form can be oriented properly.

You typically design a form as follows:

With the Forms Designer, you can also: