).
During operation, the BeanBox provides three windows. The leftmost is the bean palette, a holding area for candidate beans under test. In the middle, the BeanBox composition window provides a staging area where live beans perform. When you click on a bean in the palette and then click on a location in the composition window, the bean is instantiated and ready to test. The right window is a properties inspector window. When you select a bean in the BeanBox, this window is filled with any editable properties the bean possesses.
The BeanBox contains 16 beans. These range from simple (for example, the JellyBean, which draws a rounded rectangle and supports two properties) to more complex ones, such as the
JDBC SELECT bean, which launches a SQL SELECT statement at a Java Database Connectivity database server. The composition window is itself a container bean.
Bean Events and Bound Properties
Beans do not exist independently of each other. Multiple beans within a container must have a mechanism for communicating with one another. An important aspect of a JavaBean is its ability to trigger and/or respond to events.
To properly test the event-managing capabilities of a bean, whether as an event source or a target, you need to wire beans together. The BeanBox lets you do this. Once a bean is in the composition window, you can select it and, through the window's edit menu, browse the event-listener interfaces that the bean implements. You can connect this event-listener interface to any other bean (which becomes the receiver of the event) that implements that interface.
It works like this: Select a bean in the composition window. This will become the event-source bean. From the
menu, select the event-listener interface that you want to hook to a receiving bean. You also select the EventObject argument associated with this interface (the purpose of this argument will become clear in a moment). The BeanBox draws a rubber-band line that tracks the mouse. You then select the receiving bean (anchoring the rubber band), which causes the BeanBox to open a dialog box showing the methods in the target bean that can accept the event from the source bean. Which methods are compatible on the target depend on the EventObject you selected back on the source bean.
Pick the target method, and the BeanBox automatically creates, compiles, and loads what is referred to as an "event-adapter class." This is the actual plumbing that connects the source bean's event to the target's receiving method. Once this class is built, you can test the source and target's behavior, verifying that the source event is properly handled by the receiving bean.
The BeanBox also lets you test what are known as
"bound properties." A bound property triggers a
PropertyChange
event whenever that property is modified. Consequently, you can wire the property's event to a target bean using much the same mechanism as described above. For example, a text-display bean could properly track the color of a rectangle-drawing bean. Whenever the rectangle's color property gets modified, the text-display bean is notified.
Included with the BDK is a tutorial that guides you through the process of connecting button beans to the animated Juggling Duke bean (as shown
in the screen
). This is worthwhile for getting a quick feel for how beans perform event-handling under JDK 1.1. More useful are the later examples in the tutorial that use an analogy of water flowing from sources to destinations through pipes and valves to illustrate the dynamics of event management.
screen_link (23 Kbytes)

The BDK's BeanBox is a complete proving ground for JavaBeans.