实施绑定属性
import java.beans.PropertyChangeListener; /** 来 自 nowjava.com - 时 代 Java **/ import java.beans.PropertyChangeSupport; public class Main { 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)); } // Create the listener list. PropertyChangeSupport pceListeners = new PropertyChangeSupport(this); // The listener list wrapper methods./**N o w J a v a . c o m - 时 代 Java**/ public synchronized void addPropertyChangeListener( PropertyChangeListener listener) { pceListeners.addPropertyChangeListener(listener); }