Help is available for each task, or you can go straight to
the solution source code.
Task 1
Take the final CentralPerk.java, PerkEvent.java,
and PerkListener.java files from the
From Kiva Han to Central Perk exercise and place them in their own
package.
Create a new subdirectory, copy the files to subdirectory, and include a line as the first line of each
file that says "package DirName;", where DirName is the subdirectory you created. For
instance, if the subdirectory you created is "Marcel", the line would be "package Marcel;".
Task 2
Create the associated BeanInfo
class for CentralPerk
.
In it, set the descriptive name of the Bean to "Billboard".
The class needs to be called CentralPerkBeanInfo
and should subclass
SimpleBeanInfo
.
The getBeanDescriptor
method should look like this:
public BeanDescriptor getBeanDescriptor() {
BeanDescriptor bd =
new BeanDescriptor(CentralPerk.class);
bd.setDisplayName($quot;Billboard");
return bd;
}
A warning note about compiling the BeanInfo
class. You need to ensure your CLASSPATH
environment variable is set properly for this to find the CentralPerk.class
file. Because this
is in a package, you either need to compile from its parent directory, or include the package's base
directory in the CLASSPATH.
Task 3
The next thing you need to do is to create a manifest file for the Bean's .jar
file. Normally,
the jar
command can create the manifest for you. However, in order for the Bean-builder tool
to know that one of the .class
files is a Bean, you have to manually create a manifest file.
For every .class
file, you need to include a line of the form:
Name: Marcel/CentralPerk.class
Make sure you use a UNIX-style separator character ('/') between directory names and filename. The
DOS-style separator ('\') is not valid here.
For the class that is a Bean, include a second line after the Name:
line
Java-Bean: True
Between each entry, include a blank line.
The actual filename you use for the manifest does not matter.
Name: Marcel/CentralPerk.class
Java-Bean: True
Name: Marcel/CentralPerkBeanInfo.class
Name: Marcel/PerkEvent.class
Name: Marcel/PerkListener.class
Using a tool like make/nmake makes
this much easier, especially when the number of classes increases.
Task 4
From the directory above your package directory, create the jar file.
Assuming the manifest file is called manifest, and your classes are in the Marcel package,
the command to do this is:
jar cfm Perk.jar manifest Marcel\*.class
Task 5
Startup the BeanBox.
See the
BDK Introduction with John Wayne
exercise for instructions.
Task 6
Load the jar file with the 'LoadJar' menu choice under the 'File' menu. The Billboard
bean
should now appear in the Toolbox. Try it out.
If you get a duplicate name exception from the BeanBox when loading the .jar
file,
this means that the BeanBox locates the jar-file class in the CLASSPATH. Run the beanbox from
another directory and/or reset your CLASSPATH. The run.sh
and run.bat
scripts
in the Beanbox directory do this for you.
Copyright © 1997 MageLang Institute. All Rights Reserved.