20-CS-694 Advanced Programming Techniques Spring 2012
Applets

Interfaces, Exceptions, Graphics, Animation, Threads, Reflection, Networking, RMI, JDBC, JNI

       Previous     Next     Applet Source     All lectures

An Applet - BorderLayout

Border layout showing all five sections populated with JButtons

import java.awt.*;          // For the BorderLayout class
import javax.swing.*;       // For the JButton class
import java.applet.*;       // For the Applet class

class Prog1Frame extends JFrame {
   JButton n,s,e,w,c;

   public Prog1Frame () {
      setLayout(new BorderLayout());
      add ("North",  n = new JButton("North Button"));
      add ("South",  s = new JButton("South Button"));
      add ("East",   e = new JButton("East Button"));
      add ("West",   w = new JButton("West Button"));
      add ("Center", c = new JButton("Hello World"));
   }
}

public class Prog1 extends Applet {
   public void init () {
      Prog1Frame pf = new Prog1Frame();
      pf.setSize(400,300);
      pf.setVisible(true);
   }
}