(Apple Bug # 2671196 (lost by Apple) and 2800015 (resubmitted))
The applet above consists of 6 panels that
are switched by clicking on buttons. The applet overrides
"update", as often done to reduce flicker. However, this
overriding of update results in persistence of panels that were removed using OS
10.1 with MRJ 3.1. This behavior is not seen in other Java environments such as MRJ 2.2.4 for Macintosh OS
9 and Sun JRE 1.3 in Windows Netscape 6.
The identical applet without the update code is at this link.
That applet was an attempt to reproduce this problem in the OS X PB.
Although it did identify some error that led to crashes that is now corrected in
OS X, it turned out to be a separate problem from the update issue which now
gets submitted one revision later.
Workaround: do not override update in OS X.
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 UpdateMess 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 final void update(Graphics g) // to prevent flicker
{
paint(g);
}
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 UpdateMess