Code example for PropertyChangeEvent

Methods: getNewValue, getPropertyName

0
     * @throws java.beans.PropertyVetoException 
     *          if the recipient wishes the property 
     *          change to be rolled back. 
     */ 
    public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
        String eventName = evt.getPropertyName();
        if (eventName.equalsIgnoreCase("interest")) {
            double interest = ((Double) evt.getNewValue()).doubleValue();
            if (interest > 20.00) {
                throw new PropertyVetoException("Interest must be below 20.00", evt);
            } 
            System.out.println("Interest applied = " + interest);
        } 
    } 
}