我是个刚学JAVA不久的菜鸟哈,要做个毕业设计,这里是用卡片式的布局,然后将各个输入的值存放到数据库中,但是这样写的话,编译不会报错,运行的时候会报空指针的错误,错误如下哈:
Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1031)
    at java.awt.Container.add(Container.java:352)
    at choose$time.<init>(choose.java:93)
    at choose$TCardLayout.<init>(choose.java:49)
    at choose.<init>(choose.java:12)
    at choose.main(choose.java:304)我找不到该改哪里了,请各位大侠帮我看看哈,我急啊~~~~~~~谢谢了。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.sql.*;
import java.util.*;
public class choose extends JFrame implements ActionListener{
     JLabel time,number,word,tixing;
     
     Container content=getContentPane();
     
     TCardLayout tc1=new TCardLayout();
     time ti=new time();
     word wo=new word();
     type ty=new type();
     JPanel botton=new JPanel();
     JPanel change=new JPanel();
     
     JTextField t1=new JTextField(5);
     JTextField t2=new JTextField(5);
     JTextField t3=new JTextField(5);
     String set1,set2,words,types,stime,rowed,numbered;
     
     JButton b1,b2,b3,b4,b5;
     
    ButtonGroup group1=new ButtonGroup(); 
    JRadioButton setYesd=new JRadioButton("按照时间背诵",true);
    JRadioButton setNod=new JRadioButton("按照次数背诵",false);
   
    ButtonGroup group2=new ButtonGroup(); 
    JRadioButton setYes=new JRadioButton("需要",true);
    JRadioButton setNo=new JRadioButton("不需要",false);
   
    JComboBox cob=new JComboBox();     Statement stmt;
     PreparedStatement pstmt;
     ResultSet rs;
   public class TCardLayout extends JPanel{       //用卡片布局
     CardLayout cd=new CardLayout();
     time ti;
     word wo;
     type ty;
     public TCardLayout(){
      ti=new time();
      wo=new word();
      ty=new type();
      setLayout(cd);
      add("time",ti);//new time()
      add("word",wo);//new word()
      add("type",ty);//new type()
      }
    }
   public class time extends JPanel{
    JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); JPanel p4 = new JPanel(); JPanel p5 = new JPanel(); JPanel p6 = new JPanel(); JPanel p7 = new JPanel();    JLabel L1=new JLabel("时间间隔:");
    JLabel L2=new JLabel("是否需要提醒:");
 
    JLabel L3=new JLabel("(0到10秒之间)");
   
    public time(){     setLayout(new GridLayout(7,1));
p3.add(L1);
p3.add(t1);
p3.add(L3,Color.RED);
p4.add(L2);
group2.add(setYes);group2.add(setNo);
p4.add(setYes);p4.add(setNo);
add(p1);
add(p2);
add(p3);
add(p4);
add(p5);
add(p6);
add(p7);

    }
    }
   public class word extends JPanel{
    JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); JPanel p4 = new JPanel(); JPanel p5 = new JPanel(); JPanel p6 = new JPanel(); JPanel p7 = new JPanel();
   
    JLabel L1=new JLabel("词库选择:");   
    JLabel L2=new JLabel("每次几组单词:");
   
    JLabel L3=new JLabel("(1到20组之间)");
    JLabel L4=new JLabel("每组单词个数:");    JLabel L5=new JLabel("(1到20个之间)");
    public word(){ setBackground(Color.blue);

setLayout(new GridLayout(7, 1));
cob.addItem("四级词汇");
cob.addItem("六级词汇");
p3.add(L1);
p3.add(cob);
p4.add(L2);
p4.add(t2);
p4.add(L3,Color.RED);
p5.add(L4);
p5.add(t3);
p5.add(L5,Color.RED);
add(p1);
add(p2);
add(p3);
add(p4);
add(p5);
add(p6);
add(p7);    }
}
public class type extends JPanel{
JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); JPanel p4 = new JPanel(); JPanel p5 = new JPanel(); JPanel p6 = new JPanel(); JPanel p7 = new JPanel();

    public type(){
    setBackground(Color.blue);
    setLayout(new GridLayout(7,1));
group1.add(setYesd);group1.add(setNod);
p3.add(setYesd);p4.add(setNod);
add(p1);
add(p2);
add(p3);
add(p4);
add(p5);
add(p6);
add(p7);
    }
}
    public choose() {
     content.setLayout(new BorderLayout());
     b1=new JButton("确定");
     b2=new JButton("取消");
     b3=new JButton("时间设置");
     b4=new JButton("词库设置");
     b5=new JButton("背诵方式");
    
     botton.add(b1);botton.add(b2);
     change.add(b3);change.add(b4);change.add(b5);
     b1.addActionListener(this);
     b2.addActionListener(this);
     b3.addActionListener(this);
     b4.addActionListener(this);
     b5.addActionListener(this);
     setSize(400,300);
     setTitle("自定义设置");
           content.add(change,"North");
     content.add(tc1,"Center");
     content.add(botton,"South");
     setVisible(true);
    }
 public void actionPerformed(ActionEvent e){   //待加
    
        
     if(e.getSource()==b1)
     {
      
    
     try{
     linkSql.conn("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jc","sa","");
     String sql;
     int n=0;
    
     sql="update Optioned set stime='"+t1.getText();
     sql=sql+"',tixing='"+set1+"',ciku='"+words+"',row='"+t2.getText()+"',number='"+t3.getText()+"',types='"+set2;
     sql=sql+"' where id='1'";
     pstmt=linkSql.con.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
   int rowCount=pstmt.executeUpdate();
   if(rowCount>0)System.out.println("123");
         
     n= JOptionPane.showConfirmDialog(null,"确定要保存此设置吗?","确定",JOptionPane.YES_NO_OPTION);
     if(n==JOptionPane.YES_OPTION)
     JOptionPane.showMessageDialog(null,"保存成功");
     else
     dispose();
     }catch(Exception ee){ee.printStackTrace();}
     }
     if(e.getSource()==b2)
     {
     dispose();
     }
     if(e.getSource()==b3)
     {
     tc1.cd.show(tc1,"time");
     }
     if(e.getSource()==b4)
     {
     tc1.cd.show(tc1,"word");
     }
     if(e.getSource()==b5)
     {
     tc1.cd.show(tc1,"type");
     }
}
    
public static void main(String[] args) {
   
    new choose();
   
    
    }
}