Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Reflecting, Introspecting, and Customizing JavaBeans

By Laura Bennett
2003-10-09


Customization using customizers

Alternatively, for more sophisticated beans, the JavaBeans API has defined a customizer interface that behaves like a wizard. Wizards are graphical user interfaces that step you through a process, in this case, the process of users configuring beans. Most visual builders provide customizers for their more complicated beans. An example of a customizer from the AppletDesigner tool appears in Figure 3.

Figure 3. Customizer for TickerTape bean
Performance image

Like property editors, customizers are associated with their beans using the BeanInfo class. The BeanInfo method getBeanDescriptor() returns a BeanDescriptor that contains the bean's class and the bean's customizer class if it exists. All bean customizers must implement the java.beans.Customizer interface and extend the java.awt.Panel class.

You can see a portion of the code that implements the customizer shown in Figure 3.

Not all properties have to be implemented in the customizer. Usually, the more complicated properties are defined within the customizer. AppletDesigner ties the customizer to a bean on the Composer window. As a user customizes a bean's properties, the changes take effect dynamically. If the user cancels the customization, the bean should be reset to its initial state. If you created a customizer with your bean, you can view it by clicking Customizer on the Property Sheet in the AppletDesigner tool.



Tutorial Pages:
» Reflecting, introspecting, and customizing JavaBeans
» Reflection
» Customization using property sheets and editors
» Customization using customizers
» Summary
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT

Ask A Question
characters left.