/* * ============================================================== * DemoBorderLayout.java : Create five buttons and position them * using a border laygout .... * * Adapted from : Pantham S., Pure JFC Swing, 1999. * Modified by : Mark Austin March, 2001 * ============================================================== */ import java.awt.*; import javax.swing.*; public class DemoBorderLayout extends JApplet { Container container = null; public void init() { //1. Get a handle on the applet's content pane. container = this.getContentPane(); // Note. You don't have to set the border layout becuase // content panes use it by default. // container.setLayout(new BorderLayout()); // 2. Give some horizontal and vertical gaps between buttons. ((BorderLayout) container.getLayout()).setHgap(2); ((BorderLayout) container.getLayout()).setVgap(2); // 3. Array that contains border layout constants. String[] borderConsts = { BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, BorderLayout.CENTER }; // 4. Array that contains button names. String[] buttonNames = { "North Button", "South Button", "East Button", "West Button", "Center Button" }; // 5. Create and add buttons to the container. for (int i=0; i