Training Index

Introduction to the JavaBeans API, Magercise 1
The Beans Development Kit

by John Zukowski, MageLang Institute

[Help | API Docs | Short Course | Magercises]

There is no program to write for this Magercise. Instead, the goal is to become familiar with the BDK's BeanBox. The principal task is to connect "Start" and "Stop" command-button Beans to a juggler Bean to control the juggling activity.

The BDK must be installed before attempting this Magercise; it is available from http://java.sun.com/beans/bdk_download.html.

NOTE: Make sure the BDK is not installed into a directory with a space somewhere in the path. Connecting beans will not work. For instance, do not install the BDK into the "C:\Program Files" directory.

Magercise 1 Prerequisites

None.

Tasks

  1. Start the BeanBox, either from a command shell or a graphical file navigator such as Windows Explorer.

    With a command shell, change directories to the BDK installation directory. From there, change directories to the beanbox subdirectory and execute run.bat (Windows) or run.sh (UNIX). The run script will start the BeanBox. Also, from Windows Explorer you can simply navigate to the beanbox directory and double-click run. Note that for some releases of the BDK, the Windows install program automatically adds a BDK/BeanBox entry to the Start menu.

  2. The BeanBox consists of three windows: the palette, the worksheet area, and the property sheet for the currently selected Bean. The palette and property sheet windows appear only in design mode. To hide/show them, select the design-mode menu item under the "View" menu. For this Magercise, they should be visible.

    If you are using BDK 1.1, you get an optional fourth window, called the method tracer.

  3. The currently selected Bean has a dashed line around it (initially, the worksheet object itself). The property sheet lists the properties for the currently selected Bean. To change a property, first select it from the sheet. Selecting a property activates a custom property editor, if available; otherwise, it simply sets the focus to the text-field object for text-oriented property specification.

    For example, if you click on the "background" property, the BeanBox will activate a color editor. If you click on the "Abcde..." property, it will activate a font editor. The "name" property allows you to set an instance name for the currently selected object.

    For now, simply change the background color of the worksheet to white.

  4. To place something on the worksheet, select it from the palette (with a single mouse click) and place it on the worksheet (with a second single mouse click). First, experiment with one of the command buttons. You can then try several other Beans.

  5. Next, take a look at the ExplicitButton Bean. First, add an instance of this Bean to the worksheet. Then, choose "Report" from the "Edit" menu. Note the descriptive data that is displayed in the command window where you started the BeanBox. Optionally, if you are familiar with command window operations for redirecting output to a file, capture the output to a text file and examine it.

  6. Next, clear out the BeanBox to prepare for the main task, configuring a juggler Bean with two controls. Simply select "Clear" from the "File" menu. (Note that the BeanBox doesn't warn you that the worksheet contents have not been saved. You can also accidentally exit the BeanBox without getting a save-your-work prompt--you will lose whatever work you've done.)

  7. The next task is to configure start and stop controls for a Juggler Bean. First, select and place a Juggler and two OurButton Beans on the worksheet.

  8. Next, change the label for either OurButton Bean to "Start" and connect its action-performed functionality to the Juggler Bean's start-juggling functionality.

  9. Next, change the label for the other OurButton Bean to "Stop" and connect its action-performed functionality to the Juggler Bean's stop-juggling functionality. After setting up these connections, you will be able to use the two command buttons to control the juggling operation.

  10. Lastly, you can save your work as an applet using the "MakeApplet..." command, to use it outside the BeanBox.

  11. You can now exit the BeanBox and run the applet with appletviewer from the directory where you saved it.

Where help exists, the task numbers above are linked to the step-by-step help page.

Demonstration

There is no program to write for this Magercise. Instead, the goal is to become familiar with the BDK's BeanBox. The BeanBox looks similar to the following, except with larger windows covering much of the desktop:

Magercise 2
Short Course
About This Short Course

Copyright © 1998-1999 MageLang Institute. All Rights Reserved.