Lotus BeanMachine Reference Guide

Adding an Applet Part

Adding an Applet Part
Now let's look at how you can add an applet. You can either create an applet yourself or download one you like from the web. However you obtain an applet, importing it into BeanMachine is quick and easy.
Keep in mind that if you download a Java class that is not in a JAR, the class must be in a directory on your classpath to be recognized by BeanMachine's Bean Wizard. You can avoid this all together by putting the class file you want to import into BeanMachine's "Beans" folder. When you install BeanMachine, your class path is modified to include the "Beans" folder, therefore, the Bean Wizard will see any class you copy there automatically.
Let's try it out. To import a new part or Bean, start the Bean Wizard from the Options pulldown. On the Welcome tab of the wizard, select "Create a new part" and enter the name of the class you want to import. (A little later we'll look at modifying an existing part on BeanMachine's Palette.) Remember, the class you import can be any Java class, including applets or other kinds of Java classes. If the class is in a package, you must enter the fully qualified name of the class (e.g. java.awt.Button).
For this example, we've provided a sample applet for you to practice with. For the class name, type in:
Fireworks
(Fireworks is a Java class in your BeanMachine "Beans" folder.) When you are creating a new part with the Bean Wizard, BeanMachine automatically creates a corresponding JAR file for you.


Click Next when you are ready to continue.
After BeanMachine is done reading in the class file, the Palette tab appears. On the Palette tab of the wizard, you can enter a name for your new part, a description and choose which category your new part is kept in on BeanMachine's Palette. You can place your new part in any of BeanMachine's existing part categories, or you can make up a new category name, such as Special Effects or My Parts. In addition, the Palette tab allows you to choose an icon for your new part. You can choose your icon from the samples provided or use any GIF or JPEG image you desire. You can choose fireworks.gif
from the list if you like.
You will also see a checkbox "Part accepts children." Check this box if the new part you are importing has the ability to accept other parts inside of it. By default, most parts do not accept children so this box can usually remain unchecked. However, if you are importing a part which can accept children, such as panel, and you want the user to be able to drop additional parts inside of your part, check this box.


Click Next when you are ready to continue.
The next tab that appears is the Applet tab. This is where you specify the names and default values of any parameters that your applet expects.


The Fireworks applet takes one parameter, speed, and since 10 is a good default value, select "speed" from the list and press Edit to enter this value. If you need to access the actions, properties and events of your new part, check the "Enable advanced applet settings" checkbox.


After you enter 10
for the value of the speed parameter, click OK and then click Next on the Bean Wizard when you are ready to continue.
The next tab is the Publish tab which provides you with a view of the JAR file that will be created for you when you click Finish. This tab allows you to modify the JAR file by adding, renaming, and/or removing any additional files required by your new part. If Fireworks.class
is not already checked, check it.
The files with checkmarks will be included with your part when you publish your applet in BeanMachine. Be sure that all the files required by your new part are checked to ensure that the applet runs properly when published.


Click Next when you are ready to continue.
The next tab is the Migrate tab. This tab allows you to enter information to assist BeanMachine when opening applets (.app files) containing previous versions of your part. In most situations, you will not need to use this tab. For a detailed discussion of the functionality of the Migrate tab, see Migrating Parts.
Press Finish when you're ready to create your new part.


BeanMachine then imports your new Fireworks part and places it on the Palette under the category you specified. Now restart BeanMachine to test the new part.
To test your new Fireworks part, drop it on the applet canvas and change its size and position property so that the width is 200 and height is 100. Now press Run to see the fireworks. Note: You can only import applets that run in Netscape Navigator version 2.0 or later or Internet Explorer version 3.0 or later.
For additional instructions for customizing BeanMachine's Palette, see:
Adding a JavaBean
Adding Other Java Parts
Customizing Existing Parts
