import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
public class MyBean {
VetoableChangeSupport vceListeners = new VetoableChangeSupport(this);
int myProperty;
public int getMyProperty() {
return myProperty;
}
public void setMyProperty(int newValue) throws PropertyVetoException {
try {
vceListeners.fireVetoableChange("myProperty", new Integer(myProperty),
new Integer(newValue));
myProperty = newValue;
} catch (PropertyVetoException e) {
throw e;
}
}
public synchronized void addVetoableChangeListener(
VetoableChangeListener listener) {
vceListeners.addVetoableChangeListener(listener);
}
public synchronized void removeVetoableChangeListener(
VetoableChangeListener listener) {
vceListeners.removeVetoableChangeListener(listener);
}
}
|