Visual Java Overview

Visual Java enables you to easily design graphical user interfaces (GUIs) and integrate them into your projects.


The Visual menu in the Java WorkShop menu bar is described in The Visual Menu.

Types of GUIs

You can use Visual Java to build GUIs for both applets and standalone projects.

You can create three different types of GUI containers:

The panel is the default main container in Visual Java. When you start a new project, Visual Java automatically opens a layout window with a panel GUI in it. Choose Visual=>Main Container to change the type of a selected GUI.


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

When you create a container it is entered in the container list (the large text area to the right of the component palette). Selecting a container in the list brings its layout window to the front of the display.

Layout

Visual Java uses a grid system that enables you to place GUI components, such as buttons and text fields, in the cells of a grid. You can nest grids within cells of other grids. The components provided on the Visual Java palette are analogs of Java AWT (Abstract Windowing Toolkit) components.

The grid-based system provides a layout paradigm in which the GUI components are laid out relative to each other (as opposed to some other systems in which components are laid out in absolute positions). Relative layout works well in the Java multiplatform environment because components in the different native window toolkits vary in size and appearance.

Components

All Visual Java components (including containers) have attributes associated with them that you can use to modify the components. You can change the attributes by selecting the component in the layout grid and choosing Visual=>Edit Attributes.

Select containers (frames, panels, and dialog boxes) by clicking in the blue area around the grid or by clicking on their names in the containers list (next to the component palette on the Visual Java control panel).

All of the Visual Java components, including their special attributes are described in Visual Java Components.

Attributes common to most components are described in Laying Out GUI Interfaces.


There are two shortcut methods for opening the Attributes Editor:


Some customized components are also available using the Custom button and menu. They are described in Custom Button and Menu.

Operations

Visual Java provides an operations editor that assists you in associating event filters and actions (callbacks) to your components. The operations editor is available from the attributes editor. See Operations (Filters and Actions) for more information.

Generate the GUI

Once you have laid out the GUI to your satisfaction, you can choose Visual=>Generate to generate the Java source code that implements the GUI. This process is described in Generate Java Source Code.

The generated code is based on the information displayed in your layout, it includes changes made since you last saved the layout.

Note that the GUI is automatically generated from your most recently saved layout whenever you build the project using the Build Manager. It is generally unnecessary for you to explicitly generate the interface.

Build the Project

After you have saved the GUI interface, use the Build Manager to compile the project. The Build Manager automatically generates Java source files from the most recently saved layout file (<ProjectName>.gui), and adds the new source files to the project.

Run the Project

After you have built the project, you can run it by clicking on the Project Tester icon

If your program is a standalone application, or if it is an applet that will run on Netscape Navigator, please read about Visual Java Runtime Classes.

Groups and Shadows

Visual Java components are implemented as shadow classes (wrappers) of AWT components.

Groups are collections of shadow classes and other groups. Applications created using Visual Java are actually groups. Each Java WorkShop project contains one (and only one) group, however, projects can contain other projects.

For information about groups and shadows, see Using Groups and Shadows (Basic) and Using Groups and Shadows (Advanced).

Visual Java API Documentation

The following are links to documents that describe the Visual Java API:


See also:

The Visual Menu
Visual Java Components
Laying Out GUI Interfaces
Generating Java Source Code
Adding Operations (Filters and Actions)
Visual Java Runtime Classes
Creating Menus
Adding Custom Components and Windows
Using Groups and Shadows (Basic)
Using Groups and Shadows (Advanced)
Visual Java API Documentation
Visual Java Runtime Packages
Class Hierarchy
Index of all Fields and Methods