public class Borderlayout extends JFrame{ public Borderlayout() { // TODO Auto-generated constructor stub String[] border = {BorderLayout.CENTER,BorderLayout.NORTH,BorderLayout.SOUTH,BorderLayout.WEST,BorderLayout.EAST}; String[] buttonName = {"center button","north button","south button","west button","east button"}; setTitle("这个窗口使用边界布局管理器"); Container c = getContentPane(); setLayout(new BorderLayout()); for(int i=0;i<border.length;i++){ c.add(border[i],new JButton(buttonName[i])); } setSize(350, 200); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { // TODO Auto-generated method stub new Borderlayout(); } }