实施约束属性
/** 来 自 时 代 Java - nowjava.com**/ import java.beans.PropertyVetoException; import java.beans.VetoableChangeListener; import java.beans.VetoableChangeSupport; public class Main { int myProperty; public int getMyProperty() { return myProperty; } // Create the listener list.//from n o w j a v a . c o m - 时 代 Java VetoableChangeSupport vceListeners = new VetoableChangeSupport(this); // The listener list wrapper methods. public synchronized void addVetoableChangeListener( VetoableChangeListener listener) { vceListeners.addVetoableChangeListener(listener); } public synchronized void removeVetoableChangeListener( VetoableChangeListener listener) { vceListeners.removeVetoableChangeListener(listener); } public void setMyProperty(int newValue) throws PropertyVetoException { try { vceListeners.fireVetoableChange(