/Users/lyon/j4p/src/bookExamples/ch34BeanProperties/Bean1.java
|
1 /**
2 * Bean1.java
3 *
4 * Description: <describe the Bean1 class here>
5 * @author
6 * @version
7 */
8
9 package bookExamples.ch34BeanProperties;
10
11 import java.beans.PropertyChangeListener;
12 import java.beans.PropertyChangeSupport;
13
14
15 public class Bean1 {
16
17 private String title = "Bean1";
18
19 private String customers[] = {"tom", "dick", "harry"};
20
21 private String getCustomer(int i) {
22 if (i < 0) return null;
23 if (i >= customers.length) return null;
24 return customers[i];
25 }
26
27 public String getTitle() {
28 return title;
29 }
30
31 public void setTitle(String _title) {
32 title = _title;
33 pcs.firePropertyChange("Title", _title, title);
34 // arguments are property name, oldValue, NewValue.
35 }
36
37 PropertyChangeSupport pcs
38 = new PropertyChangeSupport(this);
39
40 // The listener list wrapper methods
41 public synchronized void addPropertyChangeListener(
42 PropertyChangeListener pcl) {
43 pcs.addPropertyChangeListener(pcl);
44 }
45
46
47 }
48
49
50 /* @(#)Bean1.java */
51