(Apple problem # 3306416)
The "g" characters in this applet get cut off in 1.4.x, suggesting that the layout manager is not sensing the font descent properly. This occurs invariably for the top and middle Labels, and occurs sometimes for the bottom Label. Adding extra space between the middle and bottom Labels doesn't help. With Internet Explorer or Netscape, which use MRJ 3.3.3, the applet behaves properly.
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.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class font_down extends Applet {
Label label1, label2, label3;
public void init()
{
setLayout(new GridBagLayout());
label1 = new Label("Label having value 1");
label1.setFont(new Font("SansSerif", Font.BOLD, 13));
constrain(this, label1, 0, 0, 1, 1, GridBagConstraints.WEST, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 0);
label2 = new Label("Label having value 2");
label2.setFont(new Font("SansSerif", Font.BOLD, 13));
constrain(this, label2, 0, 1, 1, 1, GridBagConstraints.WEST, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 0);
label3 = new Label("Label having value 3");
label3.setFont(new Font("SansSerif", Font.BOLD, 13));
constrain(this, label3, 0, 2, 1, 1, GridBagConstraints.WEST, 20, 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 font_down