JTextField and PropertyChangeListener

I have a problem with the JTextField and hooking a PropertyChangeListener to the "text" property:

JTextField field = new JTextField();

field.addPropertyChangeListener("text", new PropertyChangeListener() {

public void propertyChange(PropertyChangeEvent e) {

System.out.println("changed...");

}

});

field.setText("testing");

I have also tried the route of implementing a PropertyChangeListener interface to the class but have the same problem...

I am getting no responce at all. This was listed as a bug with java 1.4 but the bug was fixed and close as off java 5. Also, in a previous forum message it was suggested to use a DocumentListener....BUT what is wrong with this code?

Can anybody spot the problem?

Thanks in advance!

[801 byte] By [blackpearla] at [2007-11-27 10:20:42]
# 1

Nothing is wrong with the code other than there is no such property. As the

javadoc for setText() says,

Note that text is not a bound property, so no PropertyChangeEvent is fired

when it changes. To listen for changes to the text, use DocumentListener.

JayDSa at 2007-7-28 17:05:13 > top of Java-index,Desktop,Core GUI APIs...