This applet has 6 panels. The panels are displayed in the order 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 1 and so on, changed by clicking of the button. This applet works properly in Internet Explorer 5.5, Netscape 4.7 and Netscape 6 for Windows, as well as in MRJ 2.2.3 for Macintosh OS 9. It fails in MRJ 3.0 for OS X public beta: when a panel is added for a second time its components do not display properly.
This test applet demonstrates the same display problems and error messages that I see in a much larger applet. However, the large applet crashes after such re-adding of panels, with no other error messages in the console after the same error messages as generated by this test applet. Hopefully this means that the error is the same in both cases, and some extra complexity of the large applet causes the crashes, but it is hard to feel confident about this.
Addendum: Apple Developer Support informed us on 26 January 01 that this bug has been fixed. Unfortunately since the bug report consisted of a simplified applet that reproduced only some of the bug behavior in our large applet (the display problems and error messages but not the crashes) we do not know whether the serious crash part of the bug was fixed.
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, including information on how to add any necessary Java plugins.
The code for this applet is available from this link and displayed below:
import java.applet.*;
import java.awt.*;
public class TwoPages extends Applet {
Panel[] panel;
Button[] button;
Label[] label;
static final int number = 6;
public void init()
{
panel = new Panel[number];
button = new Button[number];
label = new Label[number];
for (int i=0; i<number; i++)
{
panel[i] = new Panel();
panel[i].setLayout(new BorderLayout());
button[i] = new Button(getPlace(i));
panel[i].add(getPlace(i), button[i]);
label[i] = new Label("Panel " + String.valueOf(i+1));
panel[i].add(BorderLayout.CENTER, label[i]);
}
add(panel[0]);
}
String getPlace(int index)
{
switch(index%4)
{
case 0: return(BorderLayout.EAST);
case 1: return(BorderLayout.NORTH);
case 2: return(BorderLayout.SOUTH);
default: return(BorderLayout.WEST);
}
}
public boolean action(Event evt, Object obj)
{
for (int i=0; i<number; i++)
{
if (evt.target == button[i])
{
remove(panel[i]);
if (i<(number - 1))
{
add(panel[i+1]);
panel[i+1].invalidate();
}
else
{
add(panel[0]);
panel[0].invalidate();
}
validate();
return true;
}
}
return super.action(evt, obj);
}
} // END OF Class TwoPages