Lotus BeanMachine Reference Guide

Guidelines for Writing Java Parts

The best way to write parts for the BeanMachine palette is by following the JavaBeans specification from Sun Microsystems. You can get more information about JavaBeans at www.javasoft.com. In this section, you'll learn some technical details about the structure and style that your Java code must have.
First, you must have a public constructor that takes no parameters, so that the part can be dropped in the Composer automatically. The class must also be declared public.
The Bean Wizard reads your Java class or Java applet, and tries to find properties that have matching get
and set
methods. If you have an property named myVar
that is an integer, the get
and set
methods should have the following format:
int getMyVar()
void setMyVar(int)
The properties you mark in the Bean Wizard will be displayed in the Details window on the Properties tab and on the Connections tab. You should write your get and
set
methods so that when a user sets properties in the Details window, it doesn't matter what order they are set in.
The wizard also lets you choose which methods will be available in the actions list of the Connections tab. The methods you choose for actions should not take any parameters, and they should operate very independently without expecting the user to make lots of connections or to set lots of properties. For example, if you were writing an audio part, you'd want the play action to handle all the steps of opening the sound, doing all the set up you need, and then playing the sound. Similarly, the stop action should work even if the sound isn't playing.
The Composer provides a built-in direct editing technique for all parts. To activate direct editing for your part, simply make sure it has a default property of type String. By default, the Composer will use a text field to directly edit your default string property. If you want your property to be multi-line, specify a custom property editor class of "ibm.appauthor.IBMMLEStringEditor" in the Bean Wizard. The Composer will then use a text area for direct editing.
It is also important to make sure your parts behave correctly at runtime when their properties may change at any time due to connections. If a property change effects the visual appearance of your part, you should call
repaint();
in that property's set method. Similarly, if a property change effects the size and position of your parts, you need to be sure everything gets validated. We recommend writing your own
validateAll()
method for your part and calling it in the appropriate set methods. The Blinking Text source has an example
validateAll()
method that you can cut and paste into your own part class.
