Understanding The Border Layout Policy in GUI

“Understanding The Border Layout Policy in GUI” helps you get better understanding of Border Layout System in Java.

Try to resize the window once you execute the code and see what happen!

BorderLayoutPolicy Class :

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class BorderLayoutPolicy extends JFrame implements ActionListener {

JButton north = new JButton("NorthButton");
JButton south = new JButton("SouthButton");
JButton center = new JButton("CenterButton");
JButton east = new JButton("EastButton");
JButton west = new JButton("WestButton");

public BorderLayoutPolicy() {
setTitle("An Example of understanding the BorderLayout Policy");
setLayout(new BorderLayout());
add("North", north);
add("South", south);
add("Center", center);
add("East", east);
add("West", west);

public void actionPerformed(ActionEvent e) {



The Class Tester:

public class BorderLayoutPolicyTester {

* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
new BorderLayoutPolicy();



Leave a Reply

Your email address will not be published. Required fields are marked *