Creating a Container

You begin by opening the Template Chooser from the menu bar in the main window. The top-level container that you create will hold the other components (button and label) in your application. You will create the container using the JFrame component and place it in the colorswitch package. (A package is a group of related Java classes and interfaces.)

To create the container:

  1. Choose File New.

    The Template Chooser is displayed.

  2. In the Template Chooser, expand Swing Forms, and then select JFrame.

    A description of the JFrame component appears in the pane on the right.

  3. Type ColorSwitch in the Name field and click the Browse button next to the Package field.

  4. In the New dialog box that appears, type colorswitch in the Package field and click OK.

    As you type the package name, notice that the default directory (the classpath) shown in the Directory field is simultaneously amended to include the package name.

  5. Click Finish in the Template Chooser.

    A Question alert box asks if you want to put the ColorSwitch object in the current project. A project organizes the files in your application into a single group, which makes them easier to find and work on.

  6. Click Yes if you do not have an existing project. Click No if you have an existing project; otherwise the ColorSwitch files you create will be added to your current project.

    The hierarchy in the Explorer window expands to show the colorswitch package. In addition, the workspace automatically changes to GUI Editing and the Component Inspector, Form Editor, and Source Editor are displayed. The Component Inspector provides a visual representation of the components in your application and enables you to edit their properties. The Form Editor is the layout area in which you will create the ColorSwitch GUI. The Source Editor shows the Java source code for the JFrame component. You can type only in the white areas of the Source Editor.

Next:Choosing a Layout Manager
Back:Creating the ColorSwitch Application

Legal Notices