This Magercise focuses on the design and implementation of a custom property editor, as well as its specification within the bean-info class.
The first step is to create a working directory somewhere on your filesystem, hereafter referred to as workingdir.
Next, create the directory stickfigure (all lowercase characters) directly under workingdir.
Next, (1) save all the skeleton files, except the *.java files and GIF file, within workingdir and (2) save the *.java skeleton files and GIF file within stickfigure, that is, within workingdir/stickfigure.
The next, and primary, task is to design and implement a custom "mood" property editor for the StickFigure Bean, MoodEditor. This class must extend PropertyEditorSupport and provide "mood" property-specific definitions for the following methods:
public void setValue(Object o) { }
public Object getValue() { }
public String getAsText() { }
public void setAsText(String s)
throws IllegalArgumentException { }
public String[] getTags() { }
The next task is to augment the bean-info class, StickFigureBeanInfo. Add a getPropertyDescriptors() method that returns an array of two PropertyDescriptor instances for the "mood" and "sunburned" properties, respectively.
Compile all JavaTM source files, *.java, from workingdir by including the stickfigure directory in the path specification.
Build StickFigure.jar from workingdir by executing the file MakeStickFigureJar.bat (Windows) or MakeStickFigureJar.sh (UNIX).
Next, load the StickFigure Bean into the BeanBox (or a comparable tool) using "LoadJar..." from the BeanBox "File" menu.
Lastly, note the property editor for StickFigure Bean. The "mood" property should appear in the property sheet as a drop-down list. Verify that selecting different values from the list changes the image so that it displays a smile, frown, etc.
Notice the restricted number of properties displayed in the property sheet, as well as the custom "mood" property editor.