Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
Because the more advanced JavaBean customization features are only necessary for more advanced beans, we'll start with a walk-through
of ScatterPlot, a bean that displays a scatter plot of data it retrieves from another object. The ScatterPlot class will (perhaps predictably) provide us with some gnarly customization problems. Fortunately, we'll have the tools at
hand to solve them, armed as we are with the customization interface of the JavaBeans API. We'll overcome some of the limitations
of property sheets by writing and registering a property editor for a derived type, and we'll finish by writing a complete
customizer class.
To recap from last month's column, there's a difference between a property editor and a customizer. A property editor is a class that implements the java.beans.PropertyEditor interface (although it often does so indirectly, by extending the "adapter" class java.beans.PropertyEditorSupport). Its purpose is to allow the user to edit a single property of a bean. The BeanBox container, from Sun, comes with several built-in property editors that it presents to application developers in a property sheet, as follows. (For more on the BeanBox, see my previous JavaWorld article, "The BeanBox: Sun's JavaBeans test container." Check-out the Resources section of this article to download the BeanBox.)
| Class | Property Editor |
|---|---|
| Boolean | BoolEditor |
| Byte | ByteEditor |
| Color | ColorEditor |
| Double | DoubleEditor |
| Float | FloatEditor |
| Font | FontEditor |
| Int | IntEditor |
| Long | LongEditor |
| Number | NumberEditor |
| Short | ShortEditor |
| String | StringEditor |
Built-in BeanBox property editors
When the user selects a bean in the BeanBox, the BeanBox application builds a custom property sheet for the bean. It first
introspects the bean to figure out what its properties are. Then, based on the class, the BeanBox places an instance of each
of these property editors, one per property, along with labels identifying the properties. Any properties for which it either
can't find or (for some reason) can't construct property editors are omitted from the property sheet. This means that any
properties for which no editor exists, including properties of types you've created, won't show up on the property sheet,
even if appropriate setter and getter methods have been written for them. (This is an important point, as we'll see later.)
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq