Javabean 101 16

zhaozj2021-02-11  198

Connect to Bean in Beanbox

Once Bean correctly defines an associated property, Beanbox can identify it. This is because the association property can broadcast the attribute change event. For this bean, Beanbox contains a PropertyChange interface item. For the selected bean that has already defined the associated properties, the PropertyChange interface item will appear in the Events menu.

Select Events in the EDIT menu of the bean. Once the PropertyChange is selected, connect the source bean with the Sather Bean. A straight line extends from the source bean to the listening bean. A eventTargetDialog dialog box appears. Select the corresponding listening method (this example is the ReportChange method.)

In fact, after the PropertyChange event containing the associated attribute contains the associated attribute, BeanBox generates an event connection adapter class. The event connection adapter class implements the PropertyChangeListener interface and generates the implementation of the PropertyChange method. This method is used to call the ReportChange method for listening to Bean. Since Beanbox generates an event connection adapter class, the class completes the work of the source bean to listen to Beans, so that you don't have to implement the PropertyChangeListener interface.

Constraint attribute

The constraint attribute is also an associated attribute, and additional conditions are added. For constraint properties, an external object, whether listening to bean or source bean itself, can veto the changes in attributes. The JavaBeans API provides an event mechanism for processing constraint properties, which is similar to an event mechanism for associated properties.

To achieve constraint properties, you must have:

Define the source bean of the constraint attribute. Implement the listening object of the VETOABLECHANGELISTENER interface. Contains the property name, the old value, and the new value of the new value of the attribute. (Note that this object is using the same object with the associated attribute.)

转载请注明原文地址:https://www.9cbs.com/read-4749.html

New Post(0)