public class BorderLayoutDemo { public static void main(String[] args) { Frame frame = new Frame("测试边框布局"); //frame.setBounds(100,100,600,600); frame.setLayout(new BorderLayout(30,40)); frame.add(new Button("南侧按钮"),BorderLayout.SOUTH); frame.add(new Button("北侧按钮"),BorderLayout.NORTH); frame.add(new Button("停止程序"),BorderLayout.WEST); frame.add(new Button("重启程序"),BorderLayout.EAST); frame.add(new Button("启动程序"),BorderLayout.CENTER); frame.pack();//合适的大小 frame.setVisible(true); }