Constrained Properties[size=28.3500003814697px]A constrained property is constrained by the fact that any listener can “veto” proposed changes, forcing it to revert to the old setting. The Java library contains only a few examples of constrained properties. One of them is the closed property of the JInternalFrame class. If someone tries to callsetClosed(true) on an internal frame, then all of its VetoableChangeListeners are notified. If any of them throws a PropertyVetoException, then the closed property is not changed, and the setClosedmethod throws the same exception. For example, a VetoableChangeListener may veto closing the frame if its contents have not been saved.
[size=28.3500003814697px]To build a constrained property, your bean must have the following two methods to manageVetoableChangeListener objects:
[size=28.3500003814697px]public void addVetoableChangeListener(VetoableChangeListener listener);public void removeVetoableChangeListener(VetoableChangeListener listener);
[size=28.3500003814697px]Just as there is a convenience class to manage property change listeners, there is a convenience class, called VetoableChangeSupport, that manages vetoable change listeners. Your bean should contain an object of this class.
[size=28.3500003814697px]
private VetoableChangeSupport vetoSupport = new VetoableChangeSupport(this);
[size=28.3500003814697px]Adding and removing listeners should be delegated to this object. For example:
[size=28.3500003814697px]