Help is available for each task.
Task 1
The first step is to create a working directory somewhere on your filesystem, hereafter referred to as workingdir.
To avoid confusion, create a new directory instead of using an existing directory that has existing/other files.
Task 2
Next, create the directory stickfigure (all lowercase characters) directly under workingdir.
To avoid subsequent confusion, create and verify that the directory name contains all lowercase characters. The directory stickfigure will house the StickFigure-related classes, which belong to the stickfigure package. The package and directory names must match exactly, and in some Bean-aware environments, they must be lowercase.
Task 3
Next, (1) save all the skeleton files, except the *.java files, within workingdir and (2) save the *.java skeleton files within stickfigure, that is, within workingdir/stickfigure.
After compilation, the directory stickfigure will house the StickFigure-related classes. The package and directory names must match exactly, and in some Bean-aware environments, they must be lowercase.
Task 4
The next task is to add the bound property "sunburned" to the StickFigure Bean. You must add the isSunburned() and setSunburned() access methods, as well as a boolean variable, say, hasSunburn, which is manipulated by these two methods.
The "sunburned" logic is that if a StickFigure Bean instance is sunburned, the drawing operations should use Color.red as the foreground color. That is, the principal tasks of the setSunburned() method are:
- Set hasSunburn to true or false as specified by the argument
- Set the Bean instance's "foreground" property programmatically, for example:
setForeground(Color.red);
In addition, depending on your design, you will probably need to capture and record/retain the old, pre-sunburn value for the "foreground" property, so that upon a setSunburned(false) method call, you can restore the old value.
This is a fairly simple task, requiring only approximately 15 lines of code. If you follow the design patterns, you do not need a bean-info class for this bound property to function properly. Also, do not tamper with the drawing-related methods. The drawing methods always use the current setting for "foreground", so you can change the stick figure's color simply by setting the "foreground" property.
Task 5
Compile all JavaTM source files, *.java, from workingdir by including the stickfigure directory in the path specification.
From a command window type (excluding the prompt):
C:\workingdir>javac stickfigure\*.java [DOS] or
/workingdir>javac stickfigure/*.java [UNIX]
An alternative approach, if you prefer graphical tools, is to build the stickfigure package within your Java development environment.
Verify that StickFigure.class, StickFigureEvent.class, and StickFigureListener.class exist within the stickfigure directory by typing (excluding the prompt):
C:\workingdir>dir stickfigure
10/14/98 02:12p <DIR> .
10/14/98 02:12p <DIR> ..
10/14/98 02:15p 6,638 StickFigure.class
10/14/98 02:12p 7,480 StickFigure.java
10/14/98 02:15p 956 StickFigureEvent.class
10/01/98 09:25p 831 StickFigureEvent.java
10/14/98 02:15p 298 StickFigureListener.class
10/01/98 09:27p 191 StickFigureListener.java
8 File(s) 16,394 bytes
Task 6
Build StickFigure.jar from workingdir by executing the file MakeStickFigureJar.bat (Windows) or MakeStickFigureJar.sh (UNIX).
From a command window type (excluding the prompt):
C:\workingdir>MakeStickFigureJar
jar cvmf stickfigure.txt StickFigure.jar
.\stickfigure\*.class
adding: stickfigure/StickFigure.class (in=6638)
(out=2997) (deflated 54%)
adding: stickfigure/StickFigureEvent.class (in=956)
(out=497) (deflated 48%)
adding: stickfigure/StickFigureListener.class (in=298)
(out=214) (deflated 28%)
Task 7
Next, load the StickFigure Bean into the BeanBox (or a comparable tool) using "LoadJar..." from the BeanBox "File" menu.
Start up the BeanBox, select "LoadJar..." from the BeanBox "File" menu, and then navigate to your workingdir and open/load StickFigure.jar.
Task 8
Lastly, select StickFigure from the palette and create an instance on the worksheet. Verify that the "sunburned" property is present and works properly.
When you load StickFigure.jar, it will be the last entry in the palette; you may have to scroll down in the palette to locate "StickFigure". The "sunburned" property is boolean; therefore, its property editor should be a drop-down list.
Copyright © 1998-1999
MageLang Institute.
All Rights Reserved.