The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.
In Core Java, the elements of a BorderLayout
are organized into five regions:
- North: Positioned at the top.
- South: Positioned at the bottom.
- East: Positioned on the right.
- West: Positioned on the left.
- Center: Positioned at the center.
When you add a component to a container using BorderLayout
, you can specify the region where you want the component to be placed. For example:
java
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class BorderLayoutExample {
public static void main(String[] args) {
JFrame frame = new JFrame("BorderLayout Example");
JButton button1 = new JButton("North");
JButton button2 = new JButton("South");
JButton button3 = new JButton("East");
JButton