Which containers use a Border layout as their default layout

Window, Frame and Dialog classes use a BorderLayout as their layout.

In Core Java, the containers that use a BorderLayout as their default layout are Frame, Window, and Dialog. The BorderLayout divides the container into five areas: North, South, East, West, and Center. When you create a Frame, Window, or Dialog without specifying a layout manager, it defaults to BorderLayout.

Here’s an example:

java

import java.awt.*;

public class BorderLayoutExample {
public static void main(String[] args) {
Frame frame = new Frame(“BorderLayout Example”);

Button btnNorth = new Button(“North”);
Button btnSouth = new Button(“South”);
Button btnEast = new Button(“East”);
Button btnWest = new Button(“West”);
Button btnCenter = new Button(“Center”);

frame.add(btnNorth, BorderLayout.NORTH);
frame.add(btnSouth, BorderLayout.SOUTH);
frame.add(btnEast, BorderLayout.EAST);
frame.add(btnWest, BorderLayout.WEST);
frame.add(btnCenter, BorderLayout.CENTER);

frame.setSize(300, 200);
frame.setVisible(true);
}
}

In this example, the Frame is created with a default BorderLayout, and buttons are added to the North, South, East, West, and Center regions.