Java Reference
In-Depth Information
public PropertyChangeListener [] getPropertyChangeListeners()
{
return pcs.getPropertyChangeListeners();
}
public void setName(String s)
{
String oldName = name;
name = s;
pcs.firePropertyChange(“name”, oldName, name);
}
public String getName()
{
return name;
}
public void setAccountNumber(int n)
{
int oldNumber = number;
number = n;
pcs.firePropertyChange(“accountNumber”, oldNumber, number);
}
public int getAccountNumber()
{
return number;
}
}
I want to point out a few items about the Customer bean class:
As with all JavaBeans, the Customer class implements Serializable and
contains a no-argument constructor.
■■
The Customer bean has two properties: name, which is a String, and
accountNumber, which is an int.
■■
The Customer bean class has the three methods for adding, removing,
and getting PropertyChangeListener objects. These are required for a
bean to have bound properties.
■■
Within the setName() method, the firePropertyChange() method is
invoked for the name property, passing in the old and new value of name.
■■
Within the setAccountNumber() method, the firePropertyChange()
method is invoked for the accountNumber property, passing in the old
and new value of accountNumber.
■■
Search WWH ::




Custom Search