how might one go about accessing and changing these fields of the GridBagLayout class? This isn't working!!
import java.awt.*;
public class GBag extends Panel {
public GBag() {
GridBagConstraints c = new GridBagConstraints();
Font f = new Font("Serif", 0, 36);
setFont(f);
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
c.gridx = 0;
c.gridy = 0;
add(new Button("TL"), c);
c.gridx = 1;
add(new Button("Top Middle"), c);
c.gridx = 2;
add(new Button("TR"), c);
// weights
gbl.rowWeights[0] = 1; // NULL POINTER EXCEPTION!!
gbl.columnWeights[0] = 1;
}
public static void main(
String args[]) {
Frame f = new Frame("GridBag Example");
f.add(new GBag(), BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}
Any help would be appreciated!!
Lori