KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > beans > PropertyChangeListenerProxy


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
8 package java.beans;
9
10 /**
11  * A class which extends the <code>EventListenerProxy</code> specifically
12  * for adding a named <code>PropertyChangeListener</code>. Instances of
13  * this class can be added as <code>PropertyChangeListener</code> to
14  * an object.
15  * <p>
16  * If the object has a <code>getPropertyChangeListeners()</code>
17  * method then the array returned could be a mixture of
18  * <code>PropertyChangeListener</code> and
19  * <code>PropertyChangeListenerProxy</code> objects.
20  *
21  * @see java.util.EventListenerProxy
22  * @since 1.4
23  */

24 public class PropertyChangeListenerProxy extends java.util.EventListenerProxy JavaDoc
25         implements PropertyChangeListener JavaDoc {
26
27     private String JavaDoc propertyName;
28
29     /**
30      * Constructor which binds the PropertyChangeListener to a specific
31      * property.
32      *
33      * @param listener The listener object
34      * @param propertyName The name of the property to listen on.
35      */

36     public PropertyChangeListenerProxy(String JavaDoc propertyName,
37             PropertyChangeListener JavaDoc listener) {
38         // XXX - msd NOTE: I changed the order of the arguments so that it's
39
// similar to PropertyChangeSupport.addPropertyChangeListener(String,
40
// PropertyChangeListener);
41
super(listener);
42         this.propertyName = propertyName;
43     }
44
45     /**
46      * Forwards the property change event to the listener delegate.
47      *
48      * @param evt the property change event
49      */

50     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
51         ((PropertyChangeListener JavaDoc)getListener()).propertyChange(evt);
52     }
53
54     /**
55      * Returns the name of the named property associated with the
56      * listener.
57      */

58     public String JavaDoc getPropertyName() {
59         return propertyName;
60     }
61 }
62
Popular Tags