Thursday, July 7, 2005

Binding

Today I'm evaluating JGoodies Binding. I'm impressed on how easy it is. In several hours I get my first hello world come out.
The only problem I face is that the firePropertyChange must be after the change.
This one below won't work in JComboBox

public void setFoo(String foo) {
    propertyChangeSupport.firePropertyChange(PROPERTYNAME_FOO, this.foo, foo);
    this.foo=foo;
}

But this one works.

public void setFoo(String foo) {
    String oldValue = this.foo;
    this.foo=foo;
    propertyChangeSupport.firePropertyChange(PROPERTYNAME_FOO, oldValue, foo);
}

I don't know why. I suppose Binding does not use the PropertyChangeEvent's new value.
By the way, I use binding 1.0.

No comments: