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:

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:

  1. Click on the Custom button.
  2. Choose Generic from the Custom menu and place the Generic component in a layout cell.
  3. Select the component and activate the Attribute Editor.
  4. 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:

  1. Choose Visual=>Edit Palette to activate the Palette Editor.
  2. From the choice menu in the upper left portion of the editor, choose Custom Menu.
  3. Click Add and fill in the text fields:

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:
  1. Choose Visual=>Edit Palette to activate the Palette Editor
  2. From the menu in the upper left portion of the editor, choose Palette
  3. Click Add and fill in the text fields:
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:

  1. Choose Visual=>New Window to open the New Window dialog.
  2. Choose Generic Window from the list.
  3. Click Create.
  4. Select the Generic Window in the container list (next to the component palette) and activate the Attribute Editor.
  5. 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