FileDocCategorySizeDatePackage
GridBag4.javaAPI DocExample1064Mon May 01 14:42:00 BST 2000None

GridBag4

public class GridBag4 extends JPanel

Fields Summary
GridBagConstraints
constraints
Constructors Summary
public GridBag4()


      
    setLayout(new GridBagLayout(  ));
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weighty = 1.0;
    int x, y; // for clarity
    constraints.weightx = 0.1;
    addGB(new JButton("one"),   x = 0, y = 0);
    constraints.weightx = 0.5;
    addGB(new JButton("two"),   ++x,   y);
    constraints.weightx = 1.0;
    addGB(new JButton("three"), ++x,   y);
  
Methods Summary
voidaddGB(java.awt.Component component, int x, int y)

    constraints.gridx = x;
    constraints.gridy = y;
    add(component, constraints);
  
public static voidmain(java.lang.String[] args)

    JFrame f = new JFrame("GridBag4");
    f.addWindowListener(new WindowAdapter(  ) {
      public void windowClosing(WindowEvent e) { System.exit(0); }
    });
    f.setSize(300, 100);
    f.setLocation(200, 200);
    f.setContentPane(new GridBag4(  ));
    f.setVisible(true);