Chris Johnson, Index
BorderLayout - Simpler Application Example

/*---------------------------------------------------------------------------*/
/*
* Class to create a closeable frame
*
* Author: Chris Johnson (johnson@dcs.gla.ac.uk)
* Last revision date: 5/1/2000
*
*/
 
import java.awt.*;
import java.awt.event.*;
 
public class CloseableFrame extends Frame
{
 
static private final int frame_height = 150;
static private final int frame_width = 250;
 
       public CloseableFrame()
        {
 
         addWindowListener(new
          WindowAdapter()
          {
            public void windowClosing(WindowEvent e)
             {System.exit(0);}
          }
         );
 
          setTitle("A Frame");
          setSize(frame_width, frame_height);
        }
}

/*---------------------------------------------------------------------------*/
/*
* Class to illustrate the use of a BorderLayout
*
* Author: Chris Johnson (johnson@dcs.gla.ac.uk)
* Last revision date: 5/1/2000
*
*/
 

import java.awt.*;
import java.awt.event.*;
 
public class ButtonTest extends CloseableFrame
        {
                public ButtonTest()
                {
                        setLayout(new BorderLayout());
                        add("North", new Button("North Label"));
                        add("South", new Button("South Label"));
                        add("East", new Button("East Label"));
                        add("West", new Button("West Label"));
                        add("Center", new Button("Center Label"));
                }
 
        public static void main(String [] args)
        {
                ButtonTest f = new ButtonTest();
                f.show();
        }
}


forward