// Файл InsetsDemo.java
// Демонстрирует BorderLayout со вставками.
import java.awt.*;
import java.applet.*;
import java.util.*;
/*
<applet code = "InsetsDemo" width = 400 height = 200>
</applet>
*/
public class InsetsDemo extends Applet {
public void init() {
// Установить цвет фона так, чтобы вставки были легко видимы
setBackground(Color.cyan);
setLayout(new BorderLayout());
add(new Button("This is across the top."), BorderLayout.NORTH);
add(new Label("The footer message might go here."),
BorderLayout.SOUTH);
add(new Button("Right" ), BorderLayout.EAST);
add(new Button("Left"), BorderLayout.WEST);
String msg = "The reasonable man adapts "
+ "himself to the world;\n"
+ "the unreasonable one persists in "
+ "trying to adapt the world to himself.\n"
+ "Therefore all progress depends "
+ "on the unreasonable man.\n\n"
+ " - George Bernard Shaw\n\n";
add (new TextArea (msg), BorderLayout.CENTER);
}
// добавить вставки
public Insets getInsets() {
return new Insets (10, 10, 10, 10);
}
}
Вывод апплета InsetsDemo представлен на рис.12.

Рис. 12. Вставки промежутков для выравнивания