问题描述
publicclass成绩录入界面extendsJFrame{JTextField[][]scores;String[]course;String[]name;int[][]score;public成绩录入界面()throwsIOException{JTextField[][]scores=newJTextField[10][6];for(inti=0;i<scores.length;i++){for(intj=0;j<scores[i].length;j++){scores[i][j]=newJTextField();}}JPanelp1=newJPanel();p1.setLayout(newGridLayout(11,6,0,0));p1.add(newJLabel("姓名"));DataInputStreamInput1=newDataInputStream(newFileInputStream("a.txt"));try{while(true){p1.add(newJLabel(Input1.readUTF()));}}catch(EOFExceptionex){}for(inti=0;i<scores.length;i++){for(intj=0;j<scores[i].length;j++){p1.add(scores[i][j]);}}add(p1);JPanelp2=newJPanel(newGridLayout(1,3,10,10));JButtona=newJButton("确认");JButtonb=newJButton("返回");JButtonc=newJButton("继续添加");p2.add(a);p2.add(b);p2.add(c);add(p1,BorderLayout.CENTER);add(p2,BorderLayout.SOUTH);a.addActionListener(newButtonListener());b.addActionListener(newbListener());c.addActionListener(newcListener());}privateclassButtonListenerimplementsActionListener{publicvoidactionPerformed(ActionEvente){已保存窗口frame=new已保存窗口();frame.setTitle("");frame.setSize(300,180);frame.setLocationRelativeTo(null);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);try{DataOutputStreamou=newDataOutputStream(newFileOutputStream("a.txt",true));for(inti=0;i<10;i++){try{ou.writeUTF(scores[i][0].getText());}catch(IOExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}}catch(FileNotFoundExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}}是这样每次我运行到aListener的时候经常要报错说空指针是JTEXTFIELD【】【】读不出来吗?我都卡了好久了求大神解答!!