This is what it is supposed to do. If this helps.


This file should read the records from the Graduate file first,
in sequential order as the “View Student” button is pressed.
When the program reaches the end of the Graduate Students
records, it should modify the JFrame to display
“Undergraduate Students” and then read and display the
files from the Undergraduate database

I have been working on this for weeks and have not been able to figure out what I must do to achieve this. Any help is appreciated.

import java.io.*;
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.*;

   import javax.swing.JFrame;
    public class StudentRead extends JFrame implements ActionListener
   {
   
      private JLabel gradStudentList = new JLabel("GRADUATE Student List",JLabel.CENTER);
      private JLabel undergradStudentList = new JLabel("UNDERGRADUATE Student List",JLabel.CENTER);
      private Font bigFont = new Font("Arial", Font.ITALIC, 24);
      private JLabel prompt = new JLabel("View the students",JLabel.CENTER);
      private JTextField idNumText = new JTextField(4);
      private JTextField lastNameText = new JTextField(6);
      private JTextField firstNameText = new JTextField(6);
      private JLabel idNumberLabel = new JLabel("ID Number",JLabel.CENTER);
      private JLabel lastNameLabel = new JLabel("Last name",JLabel.RIGHT);
      private JLabel firstNameLabel = new JLabel("First name",JLabel.RIGHT);
      private JButton viewStudentButton = new JButton("View Student");
      private Container con = getContentPane();
      DataInputStream gradStudentInStream;
      DataInputStream undergradStudentInStream;
   
       public StudentRead()
      {
         super("Read Student Records");
      
         try
         {
            gradStudentInStream = new DataInputStream(new FileInputStream("GradStudentsFile"));
            undergradStudentInStream = new DataInputStream(new FileInputStream("UndergradStudentsFile"));
         }
         
             catch(IOException e)
            {
               System.err.println("File not opened");
               System.exit(1);
            }
      
         setSize(300,175);
         con.setLayout(new FlowLayout());
         gradStudentList.setFont(bigFont);
      
         con.add(gradStudentList);
         con.add(prompt);
         con.add(idNumberLabel);
         con.add(idNumText);
         con.add(lastNameLabel);
         con.add(lastNameText);
         con.add(firstNameLabel);
         con.add(firstNameText);
         con.add(viewStudentButton);
         viewStudentButton.addActionListener(this);
         setVisible(true);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      
      
      }
   
       public void actionPerformed(ActionEvent e)
      {
         String lastName, firstName;
         int IdNum;
      
         try
         {
            IdNum = gradStudentInStream.readInt();
            lastName = gradStudentInStream.readUTF();
            firstName = gradStudentInStream.readUTF();
            idNumText.setText(String.valueOf(IdNum));
            lastNameText.setText(lastName);
            firstNameText.setText(firstName);
         
         }
             catch(EOFException e2)
            {
               closeFile();    
      

                   
               System.exit(0);
            }
             catch(IOException e3)
            {
               System.err.println("Error reading file");
               System.out.println("out");
               System.exit(1);
            }
      }
   
       public void closeFile()
      {
         try
         {
            gradStudentInStream.close();
            System.exit(0);
         }
         
             catch(IOException e)
            {
               System.err.println("Error closing file");
               System.exit(1);
            }
      }
   
       public static void main(String[] args)
      
      {
         StudentRead rsr = new StudentRead();
      
      }
   }

//I know this section is not correct and I know that this is where the JFrame change and read should take place

}
             catch(EOFException e2)
            {
               closeFile();    
      

               System.exit(0);
            }
             catch(IOException e3)
            {
               System.err.println("Error reading file");
               System.out.println("out");
               System.exit(1);
            }
      }
   
       public void closeFile()
      {
         try
         {
            gradStudentInStream.close();
            System.exit(0);
         }
         
             catch(IOException e)
            {
               System.err.println("Error closing file");
               System.exit(1);
            }
      }
   
       public static void main(String[] args)
      
      {
         StudentRead rsr = new StudentRead();
      
      }
   }

i think i'm following:

when you click the button, you read a line from the file and stick the student's details in the textfields. when you've reached the last student and you click the button again, you want the file to be closed off and the label at the top should change from "GRADUATE Student List" to "UNDERGRADUATE Student List" and then instead of reading from GradStudentsFile you want to start reading from UndergradStudentsFile?

what exactly is the program doing when you run it? does it throw you some errors or does it just not read from the graduates file (i noticed that you haven't put anything in there that tells it to read from undergraduates)?

Well right now it brings up the box that has the buttons for the graduate and undergraduate files. What you posted is what it is SUPPOSED to do...lol.

Once I push either button it closes.

actually since i posted that i have added this;

try
 {
 IdNum = undergradStudentInStream.readInt();
 lastName = undergradStudentInStream.readUTF();
 firstName = undergradStudentInStream.readUTF();
 idNumText.setText(String.valueOf(IdNum));
 lastNameText.setText(lastName);
 firstNameText.setText(firstName);

The catch statements are in the wrong place that I found out.

Well right now it brings up the box that has the buttons for the graduate and undergraduate files. What you posted is what it is SUPPOSED to do...lol.

Once I push either button it closes.

actually since i posted that i have added this;

try
 {
 IdNum = undergradStudentInStream.readInt();
 lastName = undergradStudentInStream.readUTF();
 firstName = undergradStudentInStream.readUTF();
 idNumText.setText(String.valueOf(IdNum));
 lastNameText.setText(lastName);
 firstNameText.setText(firstName);

The catch statements are in the wrong place that I found out.

So this is still not a solved thread, right? Please post the updated code from start to finish and provide input files.

I originally was going to post everything but last time I asked a question about something else somebody got an attitude about me posting the whole code.

Btw thank you and Easterbunny.

Here is the write file:

import java.io.*;
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.*;
 
    public class CreateGradAndUnderGradFileFrame extends JFrame implements ActionListener
   {
      private JLabel title = new JLabel ("Create Student Files",JLabel.CENTER);
      private Font bigFont = new Font ("Arial", Font.BOLD, 24);
      private JLabel prompt = new JLabel ( "Enter student data and then select a button: ",JLabel.RIGHT) ;
   
      private JTextField idNumberField = new JTextField(4);
      private JTextField lastNameField = new JTextField (8);
      private JTextField firstNameField = new JTextField (8);
   
      private JLabel idNumberLabel = new JLabel ("ID Number",JLabel.LEFT);
      private JLabel lastNameLabel= new JLabel ("Last Name",JLabel.RIGHT);
      private JLabel firstNameLabel = new JLabel ("First Name",JLabel.RIGHT);
      private JButton GraduateStudentsButton = new JButton ("Graduate Students");
      private JButton UnderGraduateStudentsButton = new JButton ("UnderGraduate Students");
      private Container con = getContentPane();
      DataOutputStream GraduateStudentsOutStream;
      DataOutputStream UnderGraduateStudentsOutStream;
      
   
       public CreateGradAndUnderGradFileFrame()
      {
         super ("GraduateStudentsData");
      
           
         try
         {
            GraduateStudentsOutStream= new DataOutputStream
               (new FileOutputStream ("GradStudentsFile"));
            UnderGraduateStudentsOutStream= new DataOutputStream
               (new FileOutputStream("UnderGradStudentsFile"));
         }
             catch (IOException e)
            {
               System.err.println("File not opened");
               System.exit(1);
            }   
      		
         con.setLayout (new FlowLayout());
         title.setFont (bigFont);
         con.add(title,JLabel.CENTER);
      
         con.add(prompt);
      
         con.add(idNumberLabel);
         con.add(idNumberField);
      
         con.add(lastNameLabel);
         con.add(lastNameField);
         con.add(firstNameLabel);
         con.add(firstNameField);
         con.add(GraduateStudentsButton);
         con.add(UnderGraduateStudentsButton);
         GraduateStudentsButton.addActionListener(this);
         UnderGraduateStudentsButton.addActionListener(this);
      
         setSize (400,200);
         setVisible(true);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         
      }
       public void actionPerformed(ActionEvent e)
      {
      
         int id= 0;
      
         try
         
         {
         
            Object source =e.getSource();
         
            if(source==GraduateStudentsButton)
            {
            
               GraduateStudentsOutStream.writeUTF(lastNameField.getText());
               GraduateStudentsOutStream.writeUTF(firstNameField.getText());
               idNumberField.setText("");
               lastNameField.setText("");
               firstNameField.setText("");
            }
            
            else  
            { 
               id=Integer.parseInt(idNumberField.getText()); 
            
               UnderGraduateStudentsOutStream.writeUTF(lastNameField.getText());
               UnderGraduateStudentsOutStream.writeUTF(firstNameField.getText()); 
            
            
               UnderGraduateStudentsOutStream.writeInt(id); 
               idNumberField.setText("");
            
               lastNameField.setText(""); 
            
               firstNameField.setText(""); 
            }
         }
             catch(NumberFormatException e2)
            {
               System.err.println("Invalid ID number");
            }
             catch(IOException e3)
            {
               System.err.println("Error writing file");
               System.exit(1);
            }
      }
       public static void main(String[]args)
      {
         CreateGradAndUnderGradFileFrame frame= new CreateGradAndUnderGradFileFrame();
         {
         }
      }
   }

Here is the read file:

import java.io.*;
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.*;

   import javax.swing.JFrame;
    public class StudentRead extends JFrame implements ActionListener
   {
   
      private JLabel gradStudentList = new JLabel("GRADUATE Student List",JLabel.CENTER);
      private JLabel undergradStudentList = new JLabel("UNDERGRADUATE Student List",JLabel.CENTER);
      private Font bigFont = new Font("Arial", Font.ITALIC, 24);
      private JLabel prompt = new JLabel("View the students",JLabel.CENTER);
      private JTextField idNumText = new JTextField(4);
      private JTextField lastNameText = new JTextField(6);
      private JTextField firstNameText = new JTextField(6);
      private JLabel idNumberLabel = new JLabel("ID Number",JLabel.CENTER);
      private JLabel lastNameLabel = new JLabel("Last name",JLabel.RIGHT);
      private JLabel firstNameLabel = new JLabel("First name",JLabel.RIGHT);
      private JButton viewStudentButton = new JButton("View Student");
      private Container con = getContentPane();
      DataInputStream gradStudentInStream;
      DataInputStream undergradStudentInStream;
   
       public StudentRead()
      {
         super("Read Student Records");
      
         try
         {
            gradStudentInStream = new DataInputStream(new FileInputStream("GradStudentsFile"));
            undergradStudentInStream = new DataInputStream(new FileInputStream("UndergradStudentsFile"));
         }
         
             catch(IOException e)
            {
               System.err.println("File not opened");
               System.exit(1);
            }
      
         setSize(300,175);
         con.setLayout(new FlowLayout());
         gradStudentList.setFont(bigFont);
      
         con.add(gradStudentList);
         con.add(prompt);
         con.add(idNumberLabel);
         con.add(idNumText);
         con.add(lastNameLabel);
         con.add(lastNameText);
         con.add(firstNameLabel);
         con.add(firstNameText);
         con.add(viewStudentButton);
         viewStudentButton.addActionListener(this);
         setVisible(true);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      
      
      }
   
       public void actionPerformed(ActionEvent e)
      {
                     String lastName, firstName;
            int IdNum;
         
            try
            {
               IdNum = gradStudentInStream.readInt();
               lastName = gradStudentInStream.readUTF();
               firstName = gradStudentInStream.readUTF();
               idNumText.setText(String.valueOf(IdNum));
               lastNameText.setText(lastName);
               firstNameText.setText(firstName);
            
            }
                catch(EOFException e2)
               {
                    System.err.println("Error reading file");
                  System.out.println("out");
                  System.exit(0);
               
         try
 {
 IdNum = undergradStudentInStream.readInt();
 lastName = undergradStudentInStream.readUTF();
 firstName = undergradStudentInStream.readUTF();
 idNumText.setText(String.valueOf(IdNum));
 lastNameText.setText(lastName);
 firstNameText.setText(firstName);
 
                   
                  System.exit(0);
               }
                catch(IOException e3)
               {
                      closeFile();  
               
               }
  
       public void closeFile()
      {
         try
         {
            gradStudentInStream.close();
            System.exit(0);
         }
         
             catch(IOException e)
            {
               System.err.println("Error closing file");
               System.exit(1);
            }
      }
   
       public static void main(String[] args)
      
      {
         StudentRead rsr = new StudentRead();
      
      }
   }
}

!!problem found!!

when you create a FileOutputStream, you must use the constructor that has the "append" boolean in it (check the java docs). i was making the same n00b mistake two weeks ago. everytime you run the file, it empties the file. what that append boolean does, is it tells the program whether it should write data to the end of the file, or whether it should start writing from the beginning of the file.

that should sort out the empty file bit (unless of course this is what you want).

also, by your actionPerformed in the StudentRead class you are missing a closing bracket thingy "}" after the "catch" statement, then you also need to take out one at the end.

i'll carry on looking through the rest of the things and point out things.

oh, you also still need to catch an IOException in StudentRead.

and you're not writing an id to the file for GraduateStudentsButton.

Thank you Easter bunny. I appreciate your time and help. Please point out anything else you might see , I would appreciate that also so I can learn from it.

ok, and the problem with the closing of the program lies in the actionPerformed method:

you tell it to read from gradStudentInStream and set the text fields to what you have read, then directly after that, you tell it to read from undergradStudentInStream and then you set the textfields to the data, but then directly after that, you tell the program to exit.

do this and watch half of it work:

public void actionPerformed(ActionEvent e)
{
	String lastName, firstName;
	int IdNum;
	try
	{
		IdNum = gradStudentInStream.readInt();
		lastName = gradStudentInStream.readUTF();
		firstName = gradStudentInStream.readUTF();
		idNumText.setText(String.valueOf(IdNum));
		lastNameText.setText(lastName);
		firstNameText.setText(firstName);
	}
	catch(EOFException e2)
	{
		System.err.println("Error reading file");
		System.out.println("out");
		System.exit(0);
	}
	catch ( java.io.IOException io )
	{
		System.err.println("io error");
	}

//	try
//	{
//		IdNum = undergradStudentInStream.readInt();
//		lastName = undergradStudentInStream.readUTF();
//		firstName = undergradStudentInStream.readUTF();
//		idNumText.setText(String.valueOf(IdNum));
//		lastNameText.setText(lastName);
//		firstNameText.setText(firstName);
//		
//		System.exit(0);
//	}
//	catch(IOException e3)
//	{
//		closeFile();
//	}
}

now you just have to figure out a way to tell it when to read from the graduate file and when to read from the undergraduate file.

It gave me this when I went to run it. It compiles ok with no errors

Exception in thread "main"

what does the code look like now? you're not running only the code i stuck up did you? sorry, bad explanation i gave. :)

you should use your StudentRead class, but then just take out the actionPerformed method you have, and put mine in. the only difference between your actionPerformed and mine, is that mine comments out the second bit of reading that you do as well as the System.exit(1).

I took out what i had under action performed and put in what you posted. IT compiles find but when I go to run it it gives me that message. I didn't touch the rest of my code...lol.

do you still have the "public static void main" at the end? it usually pops up with that error when you're trying to run a class that doesn't have the main method in it.

I originally was going to post everything but last time I asked a question about something else somebody got an attitude about me posting the whole code.

It can be a fine line between posting too much code and not enough. Not everyone agrees where that line is. Basically the idea is to try to give people enough code so that they can help fairly easily, but not so much as to swamp them, and if you post a whole bunch of code, highlight the part that's giving the error, give the exact error and the circumstances under which it occurred or use Java code tags:

[code=JAVA] // paste code here

[/code]

and point out the line number. Also, if there is an input file, provide it if possible, but trim it (and the program) down as much as possible. Ideally, post code so that the person can simply run it as is and get the exact same error. You don't need to post the whole thing each time, but if you've made changes, it needs to be clear where exactly they are.

You have some definite bracket problems here:

public void actionPerformed(ActionEvent e)
      {
                     String lastName, firstName;
            int IdNum;
         
            try
            {
               IdNum = gradStudentInStream.readInt();
               lastName = gradStudentInStream.readUTF();
               firstName = gradStudentInStream.readUTF();
               idNumText.setText(String.valueOf(IdNum));
               lastNameText.setText(lastName);
               firstNameText.setText(firstName);
            
            }
                catch(EOFException e2)
               {
                    System.err.println("Error reading file");
                  System.out.println("out");
                  System.exit(0);
               
         try
 {
 IdNum = undergradStudentInStream.readInt();
 lastName = undergradStudentInStream.readUTF();
 firstName = undergradStudentInStream.readUTF();
 idNumText.setText(String.valueOf(IdNum));
 lastNameText.setText(lastName);
 firstNameText.setText(firstName);
 
                   
                  System.exit(0);
               }
                catch(IOException e3)
               {
                      closeFile();  
               
               }

Format your code so things line up and it will be more obvious what bracket goes with what. Every starting bracket must have an ending one. I've seen a lot of posts since the one I am responding to, so it may have been pointed out.

ummm... nope. sorry. :) i've just been assuming the indents go all funny when he posts it.

Error reading file
out
Does this mean there is something amiss in my write code that when I run the StudentRead it says this after I run it?

that message seems to be coming from your catching of the end of file exception. did you tell the FileOutputStream you want to append to the end of the end?

can you upload your code as you have it now? and if anyone complains about all the code i'll engage in some fisticuffs with them. :)

Oh no...not the fisticuffs....lol. Here is my read code. I haven't had time to do anything since your suggestion to change that bottom part.

import java.io.*;
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.*;

   import javax.swing.JFrame;
    public class StudentRead extends JFrame implements ActionListener
   {
   
      private JLabel gradStudentList = new JLabel("GRADUATE Student List",JLabel.CENTER);
      private JLabel undergradStudentList = new JLabel("UNDERGRADUATE Student List",JLabel.CENTER);
      private Font bigFont = new Font("Arial", Font.ITALIC, 24);
      private JLabel prompt = new JLabel("View the students",JLabel.CENTER);
      private JTextField idNumText = new JTextField(4);
      private JTextField lastNameText = new JTextField(6);
      private JTextField firstNameText = new JTextField(6);
      private JLabel idNumberLabel = new JLabel("ID Number",JLabel.CENTER);
      private JLabel lastNameLabel = new JLabel("Last name",JLabel.RIGHT);
      private JLabel firstNameLabel = new JLabel("First name",JLabel.RIGHT);
      private JButton viewStudentButton = new JButton("View Student");
      private Container con = getContentPane();
      DataInputStream gradStudentsInStream;
      DataInputStream undergradStudentsInStream;
       
       public StudentRead()
      {
         super("Read Student Records");
      
         try
         {
            gradStudentsInStream = new DataInputStream(new FileInputStream("GradStudentsFile"));
            
            undergradStudentsInStream = new DataInputStream(new FileInputStream("UndergradStudentsFile"));
         }
         
             catch(IOException e)
            {
               System.err.println("File not opened");
               System.exit(1);
            }
      
         setSize(300,175);
         con.setLayout(new FlowLayout());
         gradStudentList.setFont(bigFont);
      
         con.add(gradStudentList);
         con.add(prompt);
         con.add(idNumberLabel);
         con.add(idNumText);
         con.add(lastNameLabel);
         con.add(lastNameText);
         con.add(firstNameLabel);
         con.add(firstNameText);
         con.add(viewStudentButton);
         viewStudentButton.addActionListener(this);
         setVisible(true);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      
      
      }
      
       public void actionPerformed(ActionEvent e)
      {
      
         {
                   
            String lastName, firstName;
         
            int IdNum;
         
            try
            
            {
            
               IdNum = gradStudentsInStream.readInt();
            
               lastName = gradStudentsInStream.readUTF();
            
               firstName = gradStudentsInStream.readUTF();
            
               idNumText.setText(String.valueOf(IdNum));
            
               lastNameText.setText(lastName);
            
               firstNameText.setText(firstName);
            
            }
            
                catch(EOFException e2)
               
               {
               
                  System.err.println("Error reading file");
               
                  System.out.println("out");
               
                  System.exit(0);
               
               }
            
                catch ( java.io.IOException io )
               
               {
               
                  System.err.println("io error");
               
               }
         
         
         
            try
            
            {
            
               IdNum = undergradStudentsInStream.readInt();
            
               lastName = undergradStudentsInStream.readUTF();
            
               firstName = undergradStudentsInStream.readUTF();
            
               idNumText.setText(String.valueOf(IdNum));
            
               lastNameText.setText(lastName);
            
               firstNameText.setText(firstName);
            
            
               System.exit(0);
            
            }
            
                catch(IOException e3)
               
               {
               
                  closeFile();
               
               }
         }
      }
     
       public static void main(String[] args)
      
      {
         StudentRead rsr = new StudentRead();
      
      }
   }

your code, including comments on the problem area (by me):

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

import javax.swing.JFrame;
public class StudentRead extends JFrame implements ActionListener
{
	private JLabel gradStudentList = new JLabel("GRADUATE Student List",JLabel.CENTER);
	private JLabel undergradStudentList = new JLabel("UNDERGRADUATE Student List",JLabel.CENTER);
	private Font bigFont = new Font("Arial", Font.ITALIC, 24);
	private JLabel prompt = new JLabel("View the students",JLabel.CENTER);
	private JTextField idNumText = new JTextField(4);
	private JTextField lastNameText = new JTextField(6);
	private JTextField firstNameText = new JTextField(6);
	private JLabel idNumberLabel = new JLabel("ID Number",JLabel.CENTER);
	private JLabel lastNameLabel = new JLabel("Last name",JLabel.RIGHT);
	private JLabel firstNameLabel = new JLabel("First name",JLabel.RIGHT);
	private JButton viewStudentButton = new JButton("View Student");
	private Container con = getContentPane();
	DataInputStream gradStudentsInStream;
	DataInputStream undergradStudentsInStream;
	
	public StudentRead()
	{
		super("Read Student Records");
		try
		{
			gradStudentsInStream = new DataInputStream(new FileInputStream("GradStudentsFile"));
			undergradStudentsInStream = new DataInputStream(new FileInputStream("UndergradStudentsFile"));
		}
		catch(IOException e)
		{
			System.err.println("File not opened");
			System.exit(1);
		}
		setSize(300,175);
		con.setLayout(new FlowLayout());
		gradStudentList.setFont(bigFont);
		con.add(gradStudentList);
		con.add(prompt);
		con.add(idNumberLabel);
		con.add(idNumText);
		con.add(lastNameLabel);
		con.add(lastNameText);
		con.add(firstNameLabel);
		con.add(firstNameText);
		con.add(viewStudentButton);
		viewStudentButton.addActionListener(this);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
			
	public void actionPerformed(ActionEvent e)
	{
		{
			String lastName, firstName;
			int IdNum;
			
			//when the button is pressed, the actionPerformed method is called, which
			//then runs the next section of code. it reads a student from the file and
			//then sticks it into the text fields. this will be done everytime the button
			//is pressed.
			try
			{
				IdNum = gradStudentsInStream.readInt();
				lastName = gradStudentsInStream.readUTF();
				firstName = gradStudentsInStream.readUTF();
				idNumText.setText(String.valueOf(IdNum));
				lastNameText.setText(lastName);
				firstNameText.setText(firstName);
			}
			//the program carries on to read the file and when you've reached the end of the file,
			//you want it to start going through the undergraduates. this "catch(EOFException e2)"
			//is the perfect place to tell your program to not read from the graduates file, but
			//instead read from the undergraduates, sort of like this:
			
			//if i have finished reading from the first file, then i shall ignore the section of code
			//above and go to the next bit of code where i read from the second file instead.
			catch(EOFException e2)
			{
				System.err.println("Error reading file");
				System.out.println("out");
				System.exit(0);
			}
			catch ( java.io.IOException io )
			{
				System.err.println("io error");
			}
			
			//comment out this bit so that only the code above runs when the press the button
			try
			{
				IdNum = undergradStudentsInStream.readInt();
				lastName = undergradStudentsInStream.readUTF();
				firstName = undergradStudentsInStream.readUTF();
				idNumText.setText(String.valueOf(IdNum));
				lastNameText.setText(lastName);
				firstNameText.setText(firstName);
				
				//this is the problem with the program exiting. as soon as it reads a student from
				//the first file (at the top there starting at line 65, it runs this try...catch block
				//and then gets to the next line and exits the program
				System.exit(0);
			}
			catch(IOException e3)
			{
				//closeFile();
			}
		}
	}
	public static void main(String[] args)
	{
		StudentRead rsr = new StudentRead();
	}
}

I did run it with the commented (Starting at line 93)out part that you had and that is when it said

Error reading file
out

ok, check your grad students file. does it have anything in it?

yes....the grad file has names in it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.