案例代码:

import javax.swing.*;
import java.awt.*;
public class ShowBorderLayout {
private JFrame f;
	private JButton jb1,jb2,jb3,jb4,jb5;
	private JLabel jl;
	private JPanel jp;
	public ShowBorderLayout() {
	  f=new JFrame("BorderLayout示例");
	  jb1=new JButton("东");
      jb2=new JButton("西");
	  jb3=new JButton("南");
	  jb4=new JButton("北");
	  jb5=new JButton("中");
	  jl=new JLabel("欢迎来到:");
	  jp=new JPanel();
	  }
   public void launchFrame(){
	  Container c=f.getContentPane();
	  c.add(jb1,BorderLayout.EAST);
	  c.add(jb2,BorderLayout.WEST);
	  c.add(jb3,BorderLayout.SOUTH);
	  c.add(jb4,BorderLayout.NORTH);
	  jp.add(jl);
	  jp.add(jb5);
	  c.add(jp,BorderLayout.CENTER);
	  f.setDefaultCloseOperation(
	  JFrame.EXIT_ON_CLOSE);
	  f.setSize(300,200);
	  f.setVisible(true);
	  }
	public static void main(String args[]) {
		ShowBorderLayout sbo=
			new ShowBorderLayout();
			sbo.launchFrame();
			}
}

案例运行图:

java tablelayout布局 java borderlayout用法_java tablelayout布局