Adding Custom Components and Windows
You can add your own custom components and windows to your
layouts. You can also incorporate your custom components
into the Visual Java component palette and Custom menu.
Custom Components
There are three ways to incorporate custom components into your
layouts:
- Use the built-in Generic Component. This is the
simplest and easiest way to add a custom component to a
layout. However, using Generic Component does not
integrate your component into Visual Java component palette.
- Add your custom component to the Custom menu.
- Add your custom component's icon to the component palette.
The Generic Component
The Custom button is similar to the buttons in the
component palette--you click it and select a component from
the choice menu to its right. Then you place the component
into the layout grid by clicking in a cell.
The Generic component in the menu is a special component
that you can use to import any custom AWT component class
that you write.
To add a custom component
to a GUI layout:
- Click on the Custom button.
- Choose Generic from the Custom menu and place the
Generic component in a layout cell.
- Select the component and activate the Attribute Editor.
- Use the
class
attribute to specify your
custom component by its full package and class name. By
default, the class
attribute of the Generic
component contains java.awt.Button
, the
regular AWT button object.
You must write your component with a null constructor and
your component must be sub-classed off of
java.awt.Component
.
Add Components to the Custom Menu
You can add your component to the Custom menu. This enables
you to select it from the menu, then click on the Custom button
to select it. No icon is required.
To add your component to the Custom menu:
- Choose Visual=>Edit Palette to activate the Palette
Editor.
- From the choice menu in the upper left portion of the editor,
choose Custom Menu.
- Click Add and fill in the text fields:
Class
The full package and class name of the component
Description
A description of the component that is displayed in the footer
of the browser when the component is selected and the cursor
is moved over the Custom button
Menu Label
The label that appears in the Custom menu
When you write a custom component and add new shadow
classes or group classes, all the standard component
attributes are available (for example,
foreground
, background
colors
, font
), because a new
shadow or group class extends an already existing class.
Any new attributes specific to the custom component are
also available in the attribute editor.
Define attributes for custom shadows or groups in the
constructor method of the class. Click here to see sample source for
LabelShadow
(the shadow class for labels).
Look for the attributes.add
calls. Note that
LabelShadow
extends
ComponentShadow
, inheriting all of the
attributes from ComponentShadow
.
Visual Java group and shadow classes are discussed in Groups and Shadows (Basics) and
Groups and Shadows (Advanced)
Add Components To The Palette
To add your component to the component palette:
- Choose Visual=>Edit Palette to activate the Palette
Editor
- From the menu in the upper left portion of the editor,
choose Palette
- Click Add and fill in the text fields:
Class
The full package and class name of the component.
Description
A description of the component that is displayed in the
footer of the browser when the cursor is moved over the
icon in the palette.
Icon
The path name of the file that contains the image displayed
in the palette
The path to the image can be a URL or (preferably) a
relative 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.
Icon images should be GIF files that are 24x24 pixels in size.
The rest of the process is identical to the one described above
in Add Components to the Custom Menu.
Custom Windows
You can incorporate custom windows into your application.
To add a custom
window:
- Choose Visual=>New Window to open the New Window
dialog.
- Choose Generic Window from the list.
- Click Create.
- Select the Generic Window in the container list (next
to the component palette) and activate the Attribute Editor.
- Use the
class
attribute to specify your
custom component by its full package and class name.
By default, the Generic Window class
attribute
contains sunsoft.jws.visual.rt.awt.RootFrame
.
Your custom window must be a subclass of
sunsoft.jws.visual.rt.awt.RootFrame
or
sunsoft.jws.visual.rt.awt.RootDialog
See also:
- Visual Java Overview
- 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
- 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