代码：

import java.beans.PropertyChangeListener;

import java.beans.PropertyChangeSupport;

public class BoundDemo {

int myProperty;

public int getMyProperty() {

return myProperty;

}

public void setMyProperty(int newValue) {

int oldValue = myProperty;

myProperty = newValue;

pceListeners.firePropertyChange("myProperty", new Integer(oldValue), new Integer(newValue));

}

// 创建监听者列表

PropertyChangeSupport pceListeners = new PropertyChangeSupport(this);

// 监听者列表打包方法

public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {

pceListeners.addPropertyChangeListener(listener);

}

public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {

pceListeners.removePropertyChangeListener(listener);

}

}