import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class BorderExample {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
JPanel panel = new JPanel(new BorderLayout());
JButton button1 = new JButton("North");
JButton button2 = new JButton("South");
JButton button3 = new JButton("East");
JButton button4 = new JButton("West");
JButton button5 = new JButton("Center");
panel.add(button1, BorderLayout.NORTH);
panel.add(button2, BorderLayout.SOUTH);
panel.add(button3, BorderLayout.EAST);
panel.add(button4, BorderLayout.WEST);
panel.add(button5, BorderLayout.CENTER);
frame.add(panel);
frame.setVisible(true);
}
}