Adding Your Own Beans to BeanBox

BeanBox uses JAR files to specify the Beans that it can use. The Beans directory of your BDK installation contains a subdirectory named jars. This directory contains the JAR files for the Beans that are used by BeanBox. All you need to do to add your Bean to BeanBox is to package it up in a JAR file and place it into the jars directory. BeanBox can work with either compressed or uncompressed JAR files.

If, for some reason, you don’t want to put your JAR file into the jars directory, you can load them at run-time by using the File menu and selecting LoadJar. This results in a dialog box that you can use to browse the file system for the JAR file that contains the Beans you want to load.

Let’s add the BeansBook.jar archive file from the previous chapter to the jars directory. This archive contains the BeansBook.util.PickleButton Bean class, along with its serialized state in file BeansBook/util/SourPickle.ser.

Using Your Beans in BeanBox

You use your Beans in BeanBox in exactly the same way that you use the Beans that were provided by the BDK. After the BeansBook.jar file is included in the jars directory, the PickleButton and SourPickle Beans will be available in the BeanBox toolbox, as shown in Figure 7.10.

The Toolbox with our own Beans added

Figure 7-10. The Toolbox with our own Beans added

If you want to use the SourPickle or PickleButton Bean on the BeanBox form, just select it and drop ...

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.