FileDocCategorySizeDatePackage
GridBag1.javaAPI DocExample1000Mon May 01 14:41:58 BST 2000None

GridBag1

public class GridBag1 extends JPanel

Fields Summary
GridBagConstraints
constraints
Constructors Summary
public GridBag1()


      
    setLayout(new GridBagLayout(  ));
    int x, y;  // for clarity
    addGB(new JButton("North"),  x = 1, y = 0);
    addGB(new JButton("West"),   x = 0, y = 1);
    addGB(new JButton("Center"), x = 1, y = 1);
    addGB(new JButton("East"),   x = 2, y = 1);
    addGB(new JButton("South"),  x = 1, y = 2);
  
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("GridBag1");
    f.addWindowListener(new WindowAdapter(  ) {
      public void windowClosing(WindowEvent e) { System.exit(0); }
    });
    f.setSize(225, 150);
    f.setLocation(200, 200);
    f.setContentPane(new GridBag1(  ));
    f.setVisible(true);