CSC 8310 -- Layout Managers

Dr. David Matuszek,   dave@acm.org
Fall 1998, Villanova University

import java.awt.*;
import java.applet.*;

public class FlowLayoutExample extends Applet
{
  public void init ()
  {
    setLayout (new FlowLayout ()); // default
    add (new Button ("One"));
    add (new Button ("Two"));
    add (new Button ("Three"));
    add (new Button ("Four"));
    add (new Button ("Five"));
    add (new Button ("Six"));
  }
}
import java.awt.*;
import java.applet.*;

public class GridLayoutExample extends Applet
{
  public void init ()
  {
    setLayout (new GridLayout (2, 4));
    add (new Button ("One"));
    add (new Button ("Two"));
    add (new Button ("Three"));
    add (new Button ("Four"));
    add (new Button ("Five"));
  }
}
import java.awt.*;
import java.applet.*;

public class BorderLayoutExample extends Applet
{
  public void init ()
  {
    setLayout (new BorderLayout ());
    add (new Button ("One"),   BorderLayout.NORTH);
    add (new Button ("Two"),   BorderLayout.WEST);
    add (new Button ("Three"), BorderLayout.CENTER);
    add (new Button ("Four"),  BorderLayout.EAST);
    add (new Button ("Five"),  BorderLayout.SOUTH);
    add (new Button ("Six"),   BorderLayout.SOUTH);
  }
}