Java Code Examples for java.beans.PropertyChangeSupport

Following code examples demonstrate how to use java.beans.PropertyChangeSupportfrom java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use java.beans.PropertyChangeSupportand various code implementation of this class.

    public void freeAll() {
	for(Entry<CONTAINED_TYPE> entry:listActionDispatcher){

This is a utility class that can be used by beans that support bound properties. It manages a list o

f 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 PropertyChangeListener can be registered for all properties or for a property specified by name.

Here is an example of PropertyChangeSupport usage that follows the rules and recommendations laid out in the JavaBeans™ specification: public class MyBean { private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); public void addPropertyChangeListener(PropertyChangeListener listener) { this.pcs.addPropertyChangeListener(listener); public void removePropertyChangeListener(PropertyChangeListener listener) { this.pcs.removePropertyChangeListener(listener); private String value; public String getValue() { return this.value; public void setValue(String newValue) { String oldValue = this.value; this.value = newValue; this.pcs.firePropertyChange("value", oldValue, newValue); [...]

A PropertyChangeSupport 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. @see VetoableChangeSupport

Read More