Confused Components

(Apple Problem ID # 2779170, Mozilla bug # 102564 (click link to see or vote for this bug))

    With Netscape 6.x for Macintosh OS 9 (tested up to build 20011022; Netscape 6.2) this applet displays a serious bug: the wrong component is displayed the first time the applet is used after the applet is loaded. 
    Clicking the button "Click this button" should show a PopupMenu with 2 options (Menuitem 1, Menuitem 2).  However, the first time the applet is used after the applet is loaded, clicking the button shows the list from the Choice component (Choice line 1, Choice line 2).  Subsequent times the button is clicked the PopupMenu is shown correctly.  
    An additional intermittent issue with this applet is that sometimes only the 2 buttons appear (disabled) and the choice does not appear. 
    This bug does not occur with Internet Explorer 5.0 in the same environment (Macintosh OS 9.2, MRJ 2.2.5), although the PopupMenu does not stay up as reported previously. The Confused Components problem does not occur using Internet Explorer 5.1.2 on OS 10.1 as long as you do not click on a MenuItem, producing after several selections of MenuItems the crashes as reported previously.  Everything is fine on Windows with multiple versions of Netscape and Internet Explorer.

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

    The source code is shown below and can be downloaded from this link:

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

public class ConfusedComponents extends Applet implements ActionListener {
Choice choice;
Button buttonThis, buttonThat;
PopupMenu myPopup;
MenuItem[] menuItem;

public void init() 
{
    buttonThis = new Button("Click this button");
    buttonThis.addActionListener(this);
    add(buttonThis); 
    buttonThat = new Button("Don't click this button");
    add(buttonThat);
    choice = new Choice();
    choice.addItem("Choice line 1 ");
    choice.addItem("Choice line 2 ");
    add(choice);
    myPopup = new PopupMenu();
    menuItem = new MenuItem[2];
    for (int i=0; i < 2; i++)
    {
        myPopup.addSeparator();
        menuItem[i] = new MenuItem("Menuitem " + String.valueOf(i+1));
        myPopup.add(menuItem[i]);
    }
    add(myPopup);
}

public void actionPerformed(ActionEvent ae)
{
    if (ae.getSource() == buttonThis) myPopup.show(buttonThat, 10, 10);
}
} // END OF Class ConfusedComponents