java GUI 小程序 求教大家 财富值没了 不好意思

疑问1: 关于name no gender这个几个标签 怎么在整个界面的中间去了?以前编程都是在jpanel的边界开始的
疑问2:整体布局不懂 不知道用了几个jpanel
这是我们去年面向对象考试卷 因为没答案 靠自己写 很多不会
希望大家能写一下 我要学习
十分感谢

按钮的触发我就不写了把布局给你贴出来

public class StudentSystem extends JFrame{
/**
 * 
 */
private static final long serialVersionUID = 1L;
 
 JTabbedPane tabbedPane = new JTabbedPane();
 JButton b1 = new JButton("Add Student");;
 JButton b2 = new JButton("Store to File");;
 JTextField t1 = new JTextField();;
 JTextField t2 = new JTextField();;
 JTextField t3 = new JTextField();;
 JLabel l1 = new JLabel("Name:");;
 JLabel l2 = new JLabel("No:");;
 JLabel l3 = new JLabel("Gender:");
 JLabel l4 = new JLabel("Tom 20100899 boy");
 JLabel l5 = new JLabel("Rose 20100812 girl");
 JLabel l6 = new JLabel("Mike 20100811 boy");
 
 JPanel jp1=new JPanel();
 StudentSystem(){
  super("学生信息增加");
  setLayout(null);
  l1.setBounds(new Rectangle(200,2,100,25));
  jp1.add(l1);
      t1.setBounds(new Rectangle(250,2,100,25));
      jp1.add(t1);
  
      l2.setBounds(new Rectangle(200,52,100,25));
  jp1.add(l2);
      t2.setBounds(new Rectangle(250,52,100,25));
      jp1.add(t2);
      
      l3.setBounds(new Rectangle(200,102,100,25));
  jp1.add(l3);
      t3.setBounds(new Rectangle(250,102,100,25));
      jp1.add(t3);
      
      b1.setBounds(new Rectangle(180,320,150,25));
  jp1.add(b1);
      b2.setBounds(new Rectangle(330,320,150,25));
      jp1.add(b2);
      
      l4.setBounds(new Rectangle(130,172,800,25));
  jp1.add(l4);
  l5.setBounds(new Rectangle(130,192,800,25));
  jp1.add(l5);
  l6.setBounds(new Rectangle(130,212,800,25));
  jp1.add(l6);
      
  jp1.setBounds(20,2,500,500);
  jp1.setLayout(null);
  add(jp1);
  
  setSize(600,400);
  setLocationRelativeTo(null);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setVisible(true);
 }
 public static void main(String[] args) {
  new StudentSystem();
 }
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-11-19
看着像是gridlayout,5行就行了,每行往里添加jpanel,然后用flowlayout