Task 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.
The BeanBox windows should be similar to the following, except larger:
Task 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.
You can specify custom colors with comma-separated red-blue-green (RGB) color
values (from 0 to 255) in the text field, or you can simply select a color,
for example, white, from the drop-down list.
Task 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.
There is no drag-and-drop behavior from the palette to the worksheet.
When you select a Bean from the palette (single click), the cursor changes to
a cross-hair shape. Then, you simply pick a location on the worksheet to
deposit the Bean and click again.
To move a Bean, move the cursor near the top edge until it changes to a
four-way cursor. At this point, you can drag the object over the worksheet.
To resize a Bean, move the cursor near a corner until it changes to a
diagonal, two-way arrow. At this point, you can resize it in both directions
simultaneously. To delete a Bean from the worksheet, select it and then
choose "Cut" from the "Edit" menu.
Task 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.
The text output describes the properties and events supported by this Bean.
For a given Bean, you should find a correspondence between the data reported
in the text output and both the properties listed in the property sheet and
the events available from the "Edit" menu.
Task 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.)
Task 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.
Task 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.
First, select an OurButton
instance. Then,
- Change the label to "Start" via the property sheet
- Select the "Edit" menu
- Select the "Events" submenu
- Select the "action" submenu
- Select the "actionPerformed" menu item
These operations enable a rubberband-like red line that you drag to the
target, in this case, the juggler Bean:
- Attach the red line to the juggler Bean by selecting it
- Select the "startJuggling" functionality from the dialog's list
- Select the "OK" button
Task 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.
First, select the other OurButton
instance. Then,
- Change the label to "Stop" via the property sheet
- Select the "Edit" menu
- Select the "Events" submenu
- Select the "action" submenu
- Select the "actionPerformed" menu item
These operations enable a rubberband-like red line that you drag to the
target, in this case, the juggler Bean:
- Attach the red line to the juggler Bean by selecting it
- Select the "stopJuggling" functionality from the dialog's list
- Select the "OK" button
Task 10
Lastly, you can save your work as an applet using the "MakeApplet..." command,
to use it outside the BeanBox.
Select "MakeApplet..." from the "File" menu. Save the applet and related
files in the default BeanBox "tmp" directory, or choose an alternate
location. Note that if you provide a name for the JAR file, you must
explicitly specify the ".jar" extension.
Task 11
You can now exit the BeanBox and run the applet with appletviewer
from the directory where you saved it.
Several files are saved as part of the "MakeApplet..." operation, all of which
are required; see the read-me file. You can view the saved worksheet Beans
with appletviewer
using the supplied HTML file.
Copyright © 1998-1999
MageLang Institute.
All Rights Reserved.