import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;public class StudenInform extends JFrame {
/**
 * @param args
 */
Container contentPane,tmpPane,tmpan,tmpPane1,tmpPane2,
tmpPane3,tmpPane4,tmpPaneCombo,tabAddComponent;
JLabel PLabel,cLabel,nameLabel,numberLabel,cLabel1,sexLabel;
JTextField nameField,numberField;
JTextArea cArea;
JButton addB,exitB;
JRadioButton radioButton1,radioButton2;
JComboBox pNameCB;
JTabbedPane commentTabPane;
JPanel queryPane;
JComboBox comboBox;

 StudenInform(String s) 
{
super(s);
contentPane = this.getContentPane();
commentTabPane = new JTabbedPane();
nameLabel = new JLabel("姓名",SwingConstants.CENTER);
nameField = new JTextField();
nameField.setColumns(15);

numberLabel = new JLabel("学号",SwingConstants.CENTER);
numberField = new JTextField();
numberField.setColumns(15);

sexLabel = new JLabel("性别:",SwingConstants.CENTER);
radioButton1 = new JRadioButton("男");
radioButton2= new JRadioButton("女");

cLabel1 = new JLabel("籍贯:\n",SwingConstants.CENTER);
String items[] = {"请从下拉列表中选择","北京","上海","福建","江西",
"河北","湖南"
};
comboBox = new JComboBox(items);
cLabel = new JLabel("个人简介:",SwingConstants.CENTER);
cArea = new JTextArea(2,20);
addB = new JButton("添加");
exitB = new JButton("取消");
this.setBounds(0,0,30,20);

tabAddComponent = new JPanel(new FlowLayout(FlowLayout.CENTER,1,1));
tabAddComponent.add(nameLabel);
tabAddComponent.add(nameField);
tabAddComponent.add(numberLabel);
tabAddComponent.add(numberField);
tabAddComponent.add(sexLabel);
tabAddComponent.add(radioButton1);
tabAddComponent.add(radioButton2);
tabAddComponent.add(cLabel1);
tabAddComponent.add(comboBox);
tabAddComponent.add(cLabel);
tabAddComponent.add(addB);
tabAddComponent.add(exitB);

tmpPane.setLayout(new GridLayout(6,1));
tmpPane.add(tabAddComponent);
tmpPane.add(tmpPane1);
tmpPane.add(tmpPane2);
tmpPane.add(tmpan);
tmpPane.add(tmpPane3);
tmpPane.add(tmpPane4);
commentTabPane.insertTab("添加学生基本信息",null,null,"",0);
commentTabPane.insertTab("查询学生基本信息",null,null,"",1);
setBounds(0,0,500,450);

commentTabPane.setSelectedIndex(0);
commentTabPane.addChangeListener(
new ChangeListener(){
public void stateChanged(ChangeEvent ce){
if(commentTabPane.getSelectedIndex()==0){
commentTabPane.setComponentAt(0, tmpPane);
}
if(commentTabPane.getSelectedIndex() == 1){
queryCom();
}
}
});
contentPane.add(tmpPane);
contentPane.add(commentTabPane);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
   }

public void queryCom(){
queryPane = new JPanel();
Object[][] tableDate = new Object[3][8];
for(int i=0; i<3; i++){
tableDate[i][0] = "姓名" + i;
for(int j= 1; j<8; j++){
tableDate[i][j]= "";
}
}
String[] name = {"姓名","学号","性别","籍贯","个人简介"};
JTable table = new JTable(tableDate,name);
JScrollPane mySP = new JScrollPane(table);
commentTabPane.setComponentAt(1, mySP);
this.setResizable(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch (Exception e){}
new StudenInform("学生信息");
}
}
运行结果出现了:Exception in thread "main" java.lang.NullPointerException
at StudenInform.<init>(StudenInform.java:65)
at StudenInform.main(StudenInform.java:114)