Panel Demo


The Code

// @author Blanca J. Polo

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

public class Panels extends Applet{

  Button bt1 = new Button (" ONE ");
  Button bt2 = new Button (" TWO ");
  Button bt3 = new Button (" THREE ");
  Button b1 = new Button (" 1 ");
  Button b2 = new Button (" 2 ");
  Button b3 = new Button (" 3 ");
  Button b4 = new Button (" 4 ");
  Button b5 = new Button (" 5 ");
  Button b6 = new Button (" 6 ");
  Button b7 = new Button (" 7 ");
  Button b8 = new Button (" 8 ");
  Button b9 = new Button (" 9 ");
  Button b10 = new Button (" 10 ");

  public void init( ){
     BorderLayout bl = new BorderLayout( );
     FlowLayout fl = new FlowLayout( );
     GridLayout gl = new GridLayout(5,2);
     Panel top = new Panel( );
     Panel bottom = new Panel( );
     this.setLayout(bl);        //the applet's layout

     this.add("North", top);
     top.setLayout(fl);         //not needed because it is the default
     top.add(bt1);
     top.add(bt2);
     top.add(bt3);
  
     this.add("Center", bottom); 
     bottom.setLayout(gl);
     bottom.add(b1);
     bottom.add(b2);
     bottom.add(b3);  
     bottom.add(b4);
     bottom.add(b5);
     bottom.add(b6);
     bottom.add(b7);
     bottom.add(b8);
     bottom.add(b9);
     bottom.add(b10);
  }   //init method finishes
     
} //end of class