Visual Java GUI Builder
With the Visual JavaTM GUI builder you can easily design
graphical user interfaces (GUIs) for your Java applets and
applications.
This page briefly explains:
Types of GUIs
Use GUI builder to create graphical interfaces for both
applets and standalone projects. You can create three types of
top-level containers for your applet or standalone project:
A container is an object that encases the elements of a GUI. When you
select a container, it is entered in the container list. Selecting a
container in the list brings its layout window to the front of the
display. For more information on containers, see Choosing Windows or Panels.
GUI Builder Palette
The palette contains all the basic components found in a typical
window, such as a text label, a scrollbar, and a radio button. See the
GUI Builder Palette page for the list of
components. All components in the GUI builder palette have attributes
that you can modify. You can change the attributes by selecting the
component in the layout grid and choosing GUI -> Edit
Attributes.
Attributes common to most components are described in the attribute editor
discussion.
Layout Grid
GUI builder uses a grid system that enables you to place GUI
components, such as buttons and text boxes, in the cells of a grid.
Grids can be nested within the cells of other grids.
The grid-based system enables you to lay out components relative to
each other. A relative layout is essential in multiplatform
environments since components in different native window toolkits vary
in size and appearance.
Importing Beans
The components provided by GUI builder are available from three
palette pages (the AWT, Panels, and Additional tabs). You can import
beans into Java WorkShop and add them to the palette pages,
or you can create additional palette pages. Beans are added by
importing their JAR files. If, however, you already have shadow
classes for components that you want to add, you can import the shadow
classes. Importing Beans into Java WorkShop is a simple
process described in Importing
Components.
For information on how beans are used in Java WorkShop, see Beans in Java WorkShop.
Development of the Application
Before you can run your application, you must generate Java source
code for the application, add behavior to the components, and build
the application.
Generating the GUI
Once you have laid out the GUI to your satisfaction, choose GUI
-> Save & Generate GUI File to generate the source code that
implements the GUI. This process is described in Generating Java Source Code.
The generated code is based on the information displayed in
your layout. If you modify the layout after you generate the code,
you must regenerate to include the changes in the source code.
The GUI is automatically generated from your most
recently saved layout whenever you build the project. It is generally
unnecessary for you to explicitly generate the code.
Adding Operations
GUI builder provides an Operations dialog box that enables you
to associate behavior (with event filters and actions) with your
components. The Operations dialog box is available from the
attribute editor. See
What Is a Component Operation? for more information.
For information on new-style (JDK1.1) and old-style (JDK1.0.2) event handling, see the JDK
documentation,
"Java AWT: Delegation Event Model." (You may have to reset the proxies
on the Java WorkShop help browser if you have difficulties reaching
the Delegation Event Model document.)
For a demonstration of how to use the new-style 1.1 events, see:
On Solaris:
install-dir-path/examples/JellyBeanExample
On Microsoft Windows 95 and Windows NT:
install-dir-path\examples\JellyBeanExample
Building the Project
After you have saved the GUI interface, compile the project. Building
in Java WorkShop automatically generates Java source files from the most
recently saved layout file
(project-name.gui
), and adds
the new source files to the project.
Running the Project
After you have built the project, you can run it by clicking the Run
button
.
If your program is a standalone application, or if it is an
applet that runs in a browser such as Netscape
NavigatorTM, you should read GUI Builder
Runtime Classes.
Groups and Shadows
GUI builder components are implemented as shadow classes
(wrappers) of AWT components. Groups are collections of shadow
classes and other groups. Applications created using GUI builder are
actually groups. Although GUI builder generates only one group, an
application can use more than one group.
In the next release of Java WorkShop, groups and shadows will not be
required.
For information about groups and shadows, see What Are Groups and Shadows? and More On Groups and Shadows.
GUI Builder Tutorials and Examples
The following examples and tutorials are available to help you learn
how to use the GUI builder to design and build applications:
- Tutorial Seven: Creating a
GUI--This tutorial shows you how to design a simple standalone
application, a calculator, using GUI builder.
- Tutorial Eight:
Creating the Clock Project--This tutorial walks you through the
entire process of creating a bean project (Clock), producing visible
and invisible beans (clock, marquee, and sound player), creating a
Desk Clock GUI project, importing the beans to the component palette,
designing the application, and adding operations to the beans.
- Card File - Examples of Creating an
Application--Card File is an extended example that highlights the
application construction features of the GUI builder. It shows you how
to create a card file that lets you look up names and phone
numbers. The example also shows you how to create your own component
that you can call up from the card file to send an Email message to
the person currently listed on the card.
See also:
- Visual Java GUI Builder API Documentation
- Visual Java GUI Builder
Runtime Packages
- Class Hierarchy
- Index of
All Fields and Methods