To include additional classes in the visual builder, you need to create a palette and then specify which classes to include on the palette.
Before including classes, you may want to refer to Imported Class Requirements and Imported Class Limitations.
Note: If the project is in a shared workarea, all users have access to the palette.
The palette name is added to the option menu in the Palette Manager.
Most of the classes are listed by the package in which they reside. To choose one or more classes:
Warning: Clicking on the box next to a package name selects all of the classes in that package. If you choose to do this, be aware that you may adversely affect the visual builder's start up performance. Also, if you include too many classes, not all of them will be visible on the palette.
A dialog opens and displays the progress of importing the selected classes onto the palette. Classes that don't meet the requirements are not imported and a message states that they were omitted.
When importing is complete, the new palette is saved in the specified directory and displayed in the palette area of the visual builder and its name is added to the Palette menu and the right-mouse-button menu in the palette area.
Before a class can be imported, it must meet the following requirements:
The standard JDK 1.1 Style events are understood by the visual builder.
The 1.0.2 events are not displayed correctly in preview, but the generated code is correct.
To handle generated events that are unknown to the visual builder, you must write an event handler in the generated .java file. To do this:
Display the .java file in the Source panel. Locate the function handleEvent(). Add your code before or after the non-editable code block.
In the following example, four lines were added to the event handler (set off by example comments). The objects, event, and action are as follows:
fromObject -- the object that produced the event you care about.
Event.SPECIAL_EVENT -- the event produced by fromObject.
toObject -- the object on which you want to perform some action.
doMyThing -- the action you want to apply to the toObject.
Example:
public boolean handleEvent(Event event) { Object arg = event.arg; boolean eventHandled = false; //{{ wiring - Begin Non-Editable Code Block //}} wiring - End Non-Editable Code Block //Begin example code (this comment doesn't exist in the real file) if (event.target == fromObject && event.id == Event.SPECIAL_EVENT) { toObject.doMyThing(); eventHandled = true; } //End the example code (this comment doesn't exist in the real file) if (!eventHandled) { super.handleEvent(event); } // always return false so that others may handle the event as well return false; }
An attribute is an abstract variable which is accessed by set/get methods. A class is said to have attributes if that class has appropriate member functions as specified by JavaSoft's JavaBeans proposal. Attributes must have properly formed accessor/modifier methods of one of the following forms:
FooType getFoo(void) void setFoo(FooType f)
-or-
Boolean isFoo(void) void setFoo(Boolean f)
Where Foo is an attribute.
Guide to the Cosmo Code Development Environment
12-96*523