TextField.textValueChanged fires on Macintosh Java 1.4 without changing text

(Apple bug # 4034839)

Summary: TextField.textValueChanged should only fire when the user enters text into a TextField or this is done with the setText method. On Macintosh Java 1.4 textValueChanged is fired by adding the TextField to the layout.

Steps to reproduce: Load the applet and check the console to see if the println method in textValueChanged has been called.

Expected results: textValueChanged should not fire unless the user enters text into the TextField (there is
no setText method in the code).

Actual results: textValueChanged fires without any user input.

Workaround: none

Isolation: expected results are obtained with Macintosh Java 1.3, Sun Java 1.5 and Microsoft Java 1.1.4.

If you have any insights, workarounds or comments about this test page please contact Mickey Segal.  A listing of  many Java resources is at this link.

Source code:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class PhantomText2 extends Applet implements TextListener{

TextField textField;

public void init()
{
    textField = new TextField(6);
    textField.addTextListener(this);
    add(textField);
}

public void textValueChanged(TextEvent te)
{
    if (te.getSource() == textField)
    {
    System.out.println("TextEvent fired");
    }
}
} // END OF Class PhantomText2