public class

PropertyChangeSupport

extends Object
implements Serializable
java.lang.Object
   ↳ java.beans.PropertyChangeSupport

Class Overview

This utility class

Summary

Public Constructors
PropertyChangeSupport(Object sourceBean)
Creates a new instance that uses the source bean as source for any event.
Public Methods
synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds a listener to a specific property.
synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Registers a listener with all properties.
void fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue)
Fires a property change of a boolean property with the given name.
void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
Fires an IndexedPropertyChangeEvent with the given name, old value, new value and index.
void fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue)
Fires a property change of an integer property with the given name.
void firePropertyChange(String propertyName, int oldValue, int newValue)
Fires a property change of an integer property with the given name.
void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
Fires a property change of a boolean property with the given name.
void firePropertyChange(PropertyChangeEvent event)
Fires a property change event to all listeners of that property.
void firePropertyChange(String propertyName, Object oldValue, Object newValue)
Fires a PropertyChangeEvent with the given name, old value and new value.
synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of listeners that registered to the property with the given name.
synchronized PropertyChangeListener[] getPropertyChangeListeners()
Returns an array with the listeners that registered to all properties.
synchronized boolean hasListeners(String propertyName)
Returns true if there are listeners registered to the property with the given name.
synchronized void removePropertyChangeListener(PropertyChangeListener listener)
removes a property change listener that was registered to all properties.
synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Removes the listener from the specific property.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PropertyChangeSupport (Object sourceBean)

Creates a new instance that uses the source bean as source for any event.

Parameters
sourceBean the bean used as source for all events.

Public Methods

public synchronized void addPropertyChangeListener (String propertyName, PropertyChangeListener listener)

Adds a listener to a specific property. Nothing happens if the property name or the listener is null.

Parameters
propertyName the name of the property
listener the listener to register for the property with the given name

public synchronized void addPropertyChangeListener (PropertyChangeListener listener)

Registers a listener with all properties.

Parameters
listener the listener to register

public void fireIndexedPropertyChange (String propertyName, int index, boolean oldValue, boolean newValue)

Fires a property change of a boolean property with the given name. If the old value and the new value are not null and equal the event will not be fired.

Parameters
propertyName the property name
index the index of the changed property
oldValue the old value
newValue the new value

public void fireIndexedPropertyChange (String propertyName, int index, Object oldValue, Object newValue)

Fires an IndexedPropertyChangeEvent with the given name, old value, new value and index. As source the bean used to initialize this instance is used. If the old value and the new value are not null and equal the event will not be fired.

Parameters
propertyName the name of the property
index the index
oldValue the old value of the property
newValue the new value of the property

public void fireIndexedPropertyChange (String propertyName, int index, int oldValue, int newValue)

Fires a property change of an integer property with the given name. If the old value and the new value are not null and equal the event will not be fired.

Parameters
propertyName the property name
index the index of the changed property
oldValue the old value
newValue the new value

public void firePropertyChange (String propertyName, int oldValue, int newValue)

Fires a property change of an integer property with the given name. If the old value and the new value are not null and equal the event will not be fired.

Parameters
propertyName the property name
oldValue the old value
newValue the new value

public void firePropertyChange (String propertyName, boolean oldValue, boolean newValue)

Fires a property change of a boolean property with the given name. If the old value and the new value are not null and equal the event will not be fired.

Parameters
propertyName the property name
oldValue the old value
newValue the new value

public void firePropertyChange (PropertyChangeEvent event)

Fires a property change event to all listeners of that property.

Parameters
event the event to fire

public void firePropertyChange (String propertyName, Object oldValue, Object newValue)

Fires a PropertyChangeEvent with the given name, old value and new value. As source the bean used to initialize this instance is used. If the old value and the new value are not null and equal the event will not be fired.

Parameters
propertyName the name of the property
oldValue the old value of the property
newValue the new value of the property

public synchronized PropertyChangeListener[] getPropertyChangeListeners (String propertyName)

Returns an array of listeners that registered to the property with the given name. If the property name is null an empty array is returned.

Parameters
propertyName the name of the property whose listeners should be returned
Returns
  • the array of listeners to the property with the given name.

public synchronized PropertyChangeListener[] getPropertyChangeListeners ()

Returns an array with the listeners that registered to all properties.

Returns
  • the array of listeners

public synchronized boolean hasListeners (String propertyName)

Returns true if there are listeners registered to the property with the given name.

Parameters
propertyName the name of the property
Returns
  • true if there are listeners registered to that property, false otherwise.

public synchronized void removePropertyChangeListener (PropertyChangeListener listener)

removes a property change listener that was registered to all properties.

Parameters
listener the listener to remove

public synchronized void removePropertyChangeListener (String propertyName, PropertyChangeListener listener)

Removes the listener from the specific property. This only happens if it was registered to this property. Nothing happens if it was not registered with this property or if the property name or the listener is null.

Parameters
propertyName the property name the listener is listening to
listener the listener to remove