To incorporate the property-change mechanism into the form, you need only
to modify the setters. In particular, you modify the definition of the
setters shown previously in Segment 921 such that they include
calls to the firePropertyChange
method with three arguments: a
property-naming string, the previous value, and the new value.
In the following example, the property-naming string is "value1"
.
Conveniently, if the old value is the same as the new value,
firePropertyChange
does nothing.
public void setValue1(int v) { int oldValue = value1; value1 = v; field1.setText(String.valueOf(value1)); firePropertyChange("value1", oldValue, value1); }