Building JAVA UI - BorderLayout Manager

 package ConsoleApplication1;

/**
* Summary description for Program
* BorderLayout Manager is default layout manager for Frame and Dialog classes.
* Create Frame with button in each border zone.
*
*/

import java.awt.*;

public class BorderExample
{
private Frame frm;
private Button bn, bs, bw, be, bc;

public BorderExample()
{
frm = new Frame("Border Layout");
bn = new Button("NORTH");
bs = new Button("SOUTH");
bw = new Button("WEST");
be = new Button("EAST");
bc = new Button("CENTER");
}
public void LAUNCHFRAME()
{
//there are two ways to assining BorderLayout.NORTH and "North" in second pattern)

//f.add(bn, BorderLayout.NORTH);
//f.add(bs, BorderLayout.SOUTH);
//f.add(bw, BorderLayout.WEST);
//f.add(be, BorderLayout.EAST);
//f.add(bc, BorderLayout.CENTER);


//Spelling,First letter Capital and Order also crucial otherwise runtime exception.

frm.add(bn, "North");
frm.add(bs, "South");
frm.add(bw, "West");
frm.add(be, "East");
frm.add(bc, "Center");

frm.setSize(180, 180);
frm.setVisible(true);
}
public static void main(String args[])
{
BorderExample borderGUI = new BorderExample();
borderGUI.LAUNCHFRAME();
}
}

Ebook Download
View all
Learn
View all