Bean Internals  «Prev  Next»
Lesson 12How do bound properties work?
Objective Learn how bound properties work.

Bound Properties Operation

The mechanism by which a bound property is connected with an interested party begins with two event listener registration methods, addPropertyChangeListener() and removePropertyChangeListener().
These methods allow an interested party (listener) to bind itself to a property, thereby making the property bound.
Following are the definitions for these methods:

public void addPropertyChangeListener  (PropertyChangeListener l);
public void removePropertyChangeListener  (PropertyChangeListener l);

When an interested party wants to bind itself to a property, it must call addPropertyChangeListener() and pass in an object implementing the PropertyChangeListener interface.
The PropertyChangeListener interface supports the propertyChange() method, which is called whenever the bound property is changed. In other words, whenever the bound property changes, the propertyChange() method is called on the listener object, which is then passed into addPropertyChangeListener(). Incidentally, the removePropertyChangeListener() method allows an interested party to break a property binding.
Both of these registration methods are implemented in the PropertyChangeSupport class, which is a utility class used in Beans that support bound properties.

bound property diagram
Bound Property Diagram

In the next lesson, bound property registration methods will be discussed.