TextField focus lost when other component validated in Macintosh Java 1.4

(Apple bug # 4034921)

 

Summary:  A TextField loses focus if another component is validated

Steps to reproduce: Type the digit 6 into the TextField in the applet.

Expected results: All typed numbers should appear in the TextField and focus should stay on the TextField.

Actual results: In Macintosh Java 1.4, focus shifts to the Checkbox and further typed digits are not entered into the TextField.

Workaround: none

Isolation: In Macintosh Java 1.3 no input appears in the TextField until the TextField is clicked, but after that the expected behavior is observed.  In Sun Java 1.5 and Microsoft Java 1.1.4 the expected behavior is observed.

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 ResetText extends Applet implements TextListener{

TextField textField;
Label label;
int counter;

public void init()
{
    textField = new TextField(20);
    textField.addTextListener(this);
    add(textField);
    textField.requestFocus();
    label = new Label("No sixes yet");
    add(label);
    Checkbox checkbox = new Checkbox("Checkbox");
    add(checkbox);
}

public void textValueChanged(TextEvent te)
{
    if (te.getSource() == textField)
    {
        if (textField.getText().endsWith("6"))
        {
            label.setText("Six # " + String.valueOf(++counter));
            label.invalidate();
            label.validate();
            validate();
        }
    }
}
} // END OF Class ResetText