JavaBean developers can add a bean to the Customizer, PropertyEditor and BeanInfo interface to describe a bean content, and Bean's users can pass through these information accompanying BEAN in the constructor. The appearance of the user is the appearance of bean and the action you should do. A bean does not have to have Beancustomizer, Prperstrpertyeditor and BeanInfo, depending on the actual situation, these are optional. When some beans are more complicated, they are provided to provide this information, which makes the bean user can be userned in Wizard. Some simple beans may not have this information, and the constructor can use the own perspective, perspective of the BEAN content, and display the information to the standard property list or event table for the user to customize Bean, the first few sections The properties, methods, and event names mentioned in the mentioned bean are named in a certain format, and the main role is to make the bean perspective for development tools. Of course, it is also to provide convenience to the programmer in a handwriting program, so that he can watch his name and know it. 3.3.1 User Miller Interface (Customizer Interface)
When a bean has its own userizer, you can show your own property table within the constructor. The Java.beans.customizer interface must be implemented when defining the userizer. For example, the following is a "button" bean user unit:
public class OurButtonCustomizer extends Panel implements Customizer {... ... / * table when implementing the general properties such as OurButtonCustomizer, which must be implemented in removePropertyChangeListener addProperChangeListener and, so, can use these tools configured by the function code is added event listener properties . * / ... ... private PropertyChangeSupport changes = new PropertyChangeSupport (this); public void addPropertyChangeListener (PropertyChangeListener l) {changes.addPropertyChangeListener (l); public void removePropertyChangeListener (PropertyChangeListener l) {changes.removePropertyChangeListener (l);}. .. ...
3.3.2 Property Editor Interface (PropertyEditor Interface)
A JavaBean provides a PropertyEditor class that creates an editor for the specified properties. This class must inherit from Java.Beans.PropertyEditorsupport classes. The programmer of the constructor and the handwritten code does not use this class directly, but instantiates and calls this class in BeanInfo in the next section. example:
public class MoleculeNameEditor extends java.beans.PropertyEditorSupport {public String [] getTags () {String resule [] = { "HyaluronicAcid", "Benzene", "buckmisterfullerine", "cyclohexane", "ethane", "water"}; return Resule;}}
In the above example, the property editor is created for the Tags property. Inside the construction tool, the properties of the MoleculeName can be selected from the drop-down table should be "Hyaluronicaid" or "Water". 3.3.3.3BeanInfo Interface Each Bean class may have a related beanfo class associated with it, which describes the appearance of this bean when the construction tool appears. BeanInfo defines attributes, methods, events, displaying their names, providing simple help notes. E.g:
public class MoleculeBeanInfo extends SimpleBeanInfo {public PropertyDescriptor [] getPropertyDescriptors () {try {PropertyDescriptor pd = new PropertyDescriptor ( "moleculeName", Molecule.class); / * pd by a reference on the MoleculeNameEditor class, and returns the acquired attribute moleculeName * / pd.setPropertyEditorClass (MoleculeNameEditor.class); PropertyDescriptor result [] = {pd}; return result;} catch (Exception ex) {System.err.println ( "MoleculeBeanInfo: unexpected exeption:" ex); return null;} }