/* The program demonstrate the use of border region * */ import javax.swing.*; import java.awt.*; import java.awt.event.*; public class BorderRegion extends JFrame { private JPanel panel; private JLabel north; private JLabel center; private JLabel west; private JLabel east; private JLabel south; public BorderRegion() { // Sets the title of the window setTitle("Border Layout Mananger"); // Sets the size of the window setSize(300, 400); // Sets the start location of the window setLocationRelativeTo(null); // Sets the action when the window is close setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a panel with border layout panel = new JPanel(); panel.setLayout(new BorderLayout()); // Create Labels north = new JLabel("North"); center = new JLabel("Center"); south = new JLabel("South"); east = new JLabel("East"); west = new JLabel("West"); // Add the label to the panel with a specify region panel.add(north, BorderLayout.NORTH); panel.add(center, BorderLayout.CENTER); panel.add(south, BorderLayout.SOUTH); panel.add(east, BorderLayout.EAST); panel.add(west, BorderLayout.WEST); // Add the panel to the content pane add(panel); // Sets the window visibility setVisible(true); } public static void main(String[] args) { new BorderRegion(); } }