BorderLayout 将容器分为EAST, SOUTH, WEST,NORTH,CENTER五个区域。
public class BorderLayoutTest { public static void main(String[] args) { var f = new Frame("BorderLayout"); f.setLayout(new BorderLayout()); f.add(new Button("south"), BorderLayout.SOUTH); f.add(new Button("north"), BorderLayout.NORTH); f.add(new Button("center")); f.add(new Button("west"),BorderLayout.WEST); f.add(new Button("east"),BorderLayout.EAST); f.pack(); f.setVisible(true); } }
output: