Module java.desktop
Package java.beans

Class VetoableChangeSupport

java.lang.Object
java.beans.VetoableChangeSupport
All Implemented Interfaces:
Serializable

public class VetoableChangeSupport extends Object implements Serializable
This is a utility class that can be used by beans that support constrained properties. It manages a list of listeners and dispatches PropertyChangeEvents to them. You can use an instance of this class as a member field of your bean and delegate these types of work to it. The VetoableChangeListener can be registered for all properties or for a property specified by name.

Here is an example of VetoableChangeSupport usage that follows the rules and recommendations laid out in the JavaBeans specification:


 public class MyBean {
     private final VetoableChangeSupport vcs = new VetoableChangeSupport(this);

     public void addVetoableChangeListener(VetoableChangeListener listener) {
         this.vcs.addVetoableChangeListener(listener);
     }

     public void removeVetoableChangeListener(VetoableChangeListener listener) {
         this.vcs.removeVetoableChangeListener(listener);
     }

     private String value;

     public String getValue() {
         return this.value;
     }

     public void setValue(String newValue) throws PropertyVetoException {
         String oldValue = this.value;
         this.vcs.fireVetoableChange("value", oldValue, newValue);
         this.value = newValue;
     }

     [...]
 }
 

A VetoableChangeSupport instance is thread-safe.

This class is serializable. When it is serialized it will save (and restore) any listeners that are themselves serializable. Any non-serializable listeners will be skipped during serialization.

Since:
1.1
See Also: