import java.beans.Beans;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
public class Main {
public static void main(String[] argv) throws Exception {
MyBean bean = (MyBean) Beans.instantiate(
ClassLoader.getSystemClassLoader(), "MyBean");
}
}
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);
}
}