1. /*
  2. * @(#)PropertyChangeListenerProxy.java 1.4 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.beans;
  8. /**
  9. * A class which extends the <code>EventListenerProxy</code> specifically
  10. * for adding a named <code>PropertyChangeListener</code>. Instances of
  11. * this class can be added as <code>PropertyChangeListener</code> to
  12. * an object.
  13. * <p>
  14. * If the object has a <code>getPropertyChangeListeners()</code>
  15. * method then the array returned could be a mixture of
  16. * <code>PropertyChangeListener</code> and
  17. * <code>PropertyChangeListenerProxy</code> objects.
  18. *
  19. * @see java.util.EventListenerProxy
  20. * @since 1.4
  21. */
  22. public class PropertyChangeListenerProxy extends java.util.EventListenerProxy
  23. implements PropertyChangeListener {
  24. private String propertyName;
  25. /**
  26. * Constructor which binds the PropertyChangeListener to a specific
  27. * property.
  28. *
  29. * @param listener The listener object
  30. * @param propertyName The name of the property to listen on.
  31. */
  32. public PropertyChangeListenerProxy(String propertyName,
  33. PropertyChangeListener listener) {
  34. // XXX - msd NOTE: I changed the order of the arguments so that it's
  35. // similar to PropertyChangeSupport.addPropertyChangeListener(String,
  36. // PropertyChangeListener);
  37. super(listener);
  38. this.propertyName = propertyName;
  39. }
  40. /**
  41. * Forwards the property change event to the listener delegate.
  42. *
  43. * @param evt the property change event
  44. */
  45. public void propertyChange(PropertyChangeEvent evt) {
  46. ((PropertyChangeListener)getListener()).propertyChange(evt);
  47. }
  48. /**
  49. * Returns the name of the named property associated with the
  50. * listener.
  51. */
  52. public String getPropertyName() {
  53. return propertyName;
  54. }
  55. }