Choosing Windows or Panels

When you run GUI builder, it provides a default container type, Panel, for your layout. A panel is a defined area of a top-level window that can contain elements of a window, such as buttons, checkboxes, and text fields; it does not create a separate window of its own. A panel cannot have a menubar. It should be used as the main container for applets that display their GUIs in a browser page or applet viewer.

To get a container other than a panel:


To change a panel container to a frame container (or frame to a panel), see Changing the Main Container Type.

To delete a container:

  1. Select the container by clicking in the background of the layout window.
  2. Choose GUI -> Delete Component.

    If the container to be deleted was never saved, pressing the Delete key removes the container; no verification window will appear.

To add a title to a top-level window:

  1. Open the attribute editor for the window by double-clicking in the background of the layout window.
  2. Type the window name in the title box.
  3. Click OK to establish the change.

Panels

If you run a project whose top-level container is a panel as a standalone application, GUI builder automatically creates a frame in which the panel can run.

Special Attributes

labelAlignment Sets the position (left, right, center) of the borderLabel on the top edge of the panel.

Frames

A frame is a top-level application window with a title and a border. A frame should be used as the main container for:

Frames are the only types of containers to which you can add menu bars.

Special Attributes

icon The path name of the file that contains the image to be contained in the icon. A semicolon followed by the size of the image (in pixels) must be appended after the path name.

The path to the image can be a URL or (preferably) a path name relative to the codebase of the applet. If the applet's .class file and image files are in the same directory, only the simple file name is required.

location Sets the initial coordinates of the frame on the screen.
menubar Invokes the Menu Editor. For details about creating menus, see Adding a Menu Bar and Menus.
resizable Determines if the size of the frame can be changed by the user.
size Sets the initial size of the frame.
visible Determines if the frame is initially visible.

Dialog Boxes

A dialog box is a pop-up window that is accessed from frames and panels.

Special Attributes

location Sets the initial coordinates of the dialog box on the screen.
modal Determines whether or not the dialog box is modal.
resizable Determines if the size of the dialog box can be changed by the user.
size Sets the initial size of the dialog box.
visible Determines if the dialog box is initially visible.

File Dialogs

A file dialog box is a point-and-click file chooser. The File dialog box cannot be shown while you are editing the interface in GUI builder because it is a modal dialog box and would block other windows. The File dialog box attributes are a straightforward mapping of the attributes for java.awt.FileDialog. See the JDK API documentation to examine java.awt.FileDialog.

To edit the File Dialog Box attributes:

If you want the file dialog to show when an action occurs (such as a button press or menu selection), you must add an operation to the component that is intended to open the file dialog box.

To show the file dialog:

  1. Select the component which opens the dialog box.
  2. Open the Attribute Editor by clicking on its button in the main toolbar.
  3. Click on the Edit operations button.
  4. Click Insert in the Operations Editor.
  5. Click the Action button.
  6. Select the action type Execute Code.
  7. Add the following code:
    gui.filedialog1.show();
    String dir = (String)gui.fileDialog1.get("directory");
                    String file = (String)gui.fileDialog1.get("file");
    

Generic Windows

A generic window is a custom window that you can incorporate into your application. For more information see Adding Custom Components and Windows

See also:

GUI Builder Palette
Laying Out the Interface
Changing the Main Container Type
Generating Java Source Code
Adding Operations to Components

Visual Java GUI Builder API Documentation
Visual Java GUI Builder Runtime Packages
Class Hierarchy
Index of all Fields and Methods