I am not seeing why this code will not generate the output to my JFrame after it takes the input from the text file? How can I tweak this code to do that? Take input from file and display it on JFrame...

                    JTabbedPane jtpane=new JTabbedPane();
                    JPanel jpan=new JPanel();
                    JTextArea txt=new JTextArea();
                        FileReader f = null;
                        try {
                            f = new FileReader("PatientCollect.txt");
                        } 
                        catch (FileNotFoundException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }

                        BufferedReader brk=new BufferedReader(f);       
                        String s;
                        try {
                            while((s=brk.readLine())!=null){
                            txt.append(s);
                            }
                        } 
                        catch (IOException e1) {
                            e1.printStackTrace();
                        }
                        jpan.add(txt);
                        jtpane.addTab("Tab1",txt);
                        this.add(jtpane);   this.setVisible(true);

Good catch! But now another issue which I've been troubleshooting for hours, in c++ this would have been easier...I just can't get this loop to take in the records below without giving me an input mismatch exception or null pointer exception...

4
Derek Jeter 100 6 26 1974
Alex Rodriguez 300 7 27 1975
Mariano Rivera 270 11 29 1969
Robinson Cano 400 11 22 1982

public void Read(Scanner s)
    {
        s=new Scanner("PatientCollectRec.txt");
        m_NumElements=s.nextInt(); //takes in the number '4' (supposed to)

        //loop to read-in values of array records
        for(int i=0; i<=m_NumElements; i++)
        {
        String fn=s.next();
        m_Patient[i].SetFirstName(fn);
        String ln=s.next();
        m_Patient[i].SetLastName(ln);
        int pId=s.nextInt();
        m_Patient[i].SetId(pId);
        int m=s.nextInt();
        DOB.SetMonth(m);
        int d=s.nextInt();
        DOB.SetDay(d);
        int y=s.nextInt();
        DOB.SetYear(y);
        }
    }
This article has been dead for over six months. Start a new discussion instead.