The layout manager has the concept of four sides and an intermediate area. When we add something to the panel using BorderLayout, we must use the Add () method to take a string object as its first argument, and the string must be specified (correct capitalization) "North" (Upper), "South" (Next), "West" (left), " East "(right) or" Center ". If we misspell or not capitalize, we get a compile-time error, and the program doesn't run as you would expect. Fortunately, we will soon find more improvements in Java 1.1.
This is a simple example of a program:
: Borderlayout1.java
//demonstrating the BorderLayout
import java.awt.*;
Import java.applet.*;
public class BorderLayout1 extends applets {public
void init () {
int i = 0;
SetLayout (New BorderLayout ());
Add ("North", New button ("button" + i++));
Add ("South", New button ("button" + i++));
Add ("East", New button ("button" + i++));
Add ("West", New button ("button" + i++));
Add ("Center", New button ("button" + i++));
}
///:~
In addition to every position in center, when the element expands to its maximum in other spaces, we compress it to the smallest size suitable for the space. However, "center" expands to occupy only the central position.
BorderLayout is the default layout manager for Applications and dialog boxes.