(Apple # 3590162)
STEPS TO REPRODUCE
Observe the applet above using Safari running Java 1.4.
RESULTS
The components overlap. Rarely this happens when the applet is first loaded, but
it always happens within a few clicks of Safari's "Reload the current page"
button.
REGRESSION
No problem on Windows (Microsoft JVM or Sun JVM 1.4.x or 1.5 beta) or Java 1.3.x
in other OS X browsers.
Source code:
import java.applet.*;
import java.awt.*;
public class into_lap extends Applet {
public void init()
{
setBackground(new Color(255, 240, 255));
setLayout(new GridBagLayout());
TextField tf = new TextField();
constrain(this, tf, 0, 0, 1, 1,
GridBagConstraints.NORTH, 0, 0, 0, 0,
GridBagConstraints.NONE, 0, 0);
Label label = new Label("Text in label");
constrain(this, label, 1, 0, 1, 1,
GridBagConstraints.NORTH, 0, 0, 0, 0,
GridBagConstraints.NONE, 0, 0);
TextField tf2 = new TextField();
constrain(this, tf2, 2, 0, 1, 1,
GridBagConstraints.NORTH, 0, 0, 0, 0,
GridBagConstraints.NONE, 0, 0);
Label label2 = new Label("More Text in label");
constrain(this, label2, 3, 0, 1, 1,
GridBagConstraints.NORTH, 0, 0, 0, 0,
GridBagConstraints.NONE, 0, 0);
Button button = new Button("Some button");
constrain(this, button, 4, 0, 1, 1,
GridBagConstraints.NORTH, 0, 0, 0, 0,
GridBagConstraints.NONE, 0, 0);
}
static final void constrain(Container container, Component component, int grid_x,
int grid_y,
int grid_width, int grid_height, int anchor, int topPad, int
leftPad, int bottomPad,
int rightPad, int fill, double weightx, double weighty)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = grid_x;
c.gridy = grid_y;
c.gridwidth = grid_width;
c.gridheight = grid_height;
c.anchor = anchor;
c.insets.top = topPad;
c.insets.left = leftPad;
c.insets.bottom= bottomPad;
c.insets.right = rightPad;
c.fill = fill;
c.weightx = weightx;
c.weighty = weighty;
((GridBagLayout)container.getLayout()).setConstraints(component,
c);
container.add(component);
}
} // END OF Class into_lap
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.