Java Beans  «Prev  Next»
Lesson 4Beanbox Test Container
ObjectiveLearn the benefits of the BeanBox test container.

Benefits of the Beanbox Test Container

To run the BeanBox, execute the run.bat file, which is located in the beanbox directory beneath the main Bdk directory. The run.bat file makes use of the Java interpreter provided with the JDK. The Java interpreter is located in the JDK bin directory beneath the main jdk directory. This directory must be included in your system path in order for the run.bat file to function properly.

Getting to know the BeanBox

The ToolBox window displays all of the Beans installed in the BeanBox. These are the Beans available to be tested in the BeanBox and consist of the example Beans provided with the BDK. Notice that some of the Beans have graphical icons associated with them to make their usage a little more obvious. The ToolBox window is where you select Beans to be inserted in the BeanBox window for testing.
Diagram of ToolBox Window
Toolbox window displaying beans installed in the window.


The BeanBox user Interface
When the BeanBox is running, it displays three different windows:

The BeanBox Window

The BeanBox window is where Beans are inserted and tested. This window is similar to a form design window in an application builder tool in that you lay out Beans in the BeanBox window and visually manipulate them as desired. The BeanBox window also serves as the main application window for the BeanBox application since it contains the menu of available BeanBox commands.

Note that applets created via beans.instantiate run in a slightly different environment than applets running inside browsers. In particular, bean applets have no access to "parameters", so they may wish to provide property get and set methods to set parameter values. We advise bean-applet developers to test their bean-applets against both the JDK appletviewer (for a reference browser environment) and the BDK BeanBox (for a reference bean container).

The BeanBox Window

Beanbox Window
Beanbox Window

The BeanBox, from Oracle (formerly Sun Microsystems), eases the development of JavaBeans by providing a test container for the components. The BeanBox can test that the code you wrote for your bean works properly inside a container.

Beanbox Properties Window

The Properties window provides an interface for editing the properties of a Bean, without any additional programming effort. You will learn about Bean properties a little later in the course.

Java Properties window

BeanBox tool

The BeanBox tool is a sample Bean container that comes with the Beans Development Kit (BDK). It allows you to test the functionality of your Beans, including properties, events, and serialization. BeanBox is not an application development tool, nor does it try to be one. It is designed to be a simple testing tool, and it serves this purpose well enough. You should keep in mind that the user interface and features of BeanBox are not intended to be a guideline for application tools to follow. Commercial development tools that work with Beans are free to use any preferred mechanisms for assembling components into applications. In fact, those mechanisms are what help differentiate one tool from another. This module does not try to cover every aspect of BeanBox. We will just look at some of the features that will be helpful in testing your work. BeanBox allows you to select Beans from a palette and drop them onto a form. It provides a property sheet for setting the values of a Bean's properties, and it allows you to connect event sources and event targets by visually associating them. BeanBox also lets you save the entire state of your form by serializing all of the Beans; you can subsequently reload the form and its constituent Beans.

Raising and Handling of Events

An event is something of importance that happens at a specific point in time. An event can take place due to a user action such as
  1. a mouse click or
  2. when the user clicks a mouse button,
an event takes place. Events can also be initiated by other means. Imagine the heating system in your house. It contains a thermostat that sets the desired comfort temperature, keeps track of the current ambient temperature, and notifies the boiler when its services are required. If the thermostat is set to keep the room at 73 degrees Fahrenheit, it will notify the boiler to start producing heat if the temperature drops below that threshold. Components will send notifications to other objects when an event takes place in which those objects have expressed an interest.
In the next lesson you learn how to use the BeanBox to test Beans.

SEMrush Software