I have to write a program that will have a gui interface, and will have a data file with information stored on it like this.
John 9503
Fred 1111
MIke 1211

Well the program will allow the user to input either the name of the person or the id # of the person. And the program will basically do a search of the file and then return either name or id depending which one was inputted by the user.

I have already set up the GUI interface for the program but I cannot figure what I need to do next to get the info from the file etc....... I do know that the information from the file has to be read into an array but I can't figure out how to get it done.
Anyone that can help. I will greatly appreciate.

here is the code of what i have as of right now.

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

public class nameid extends JFrame
JLabel NameL, RankL;

JTextField NameTF, RankTF;

JButton findnameB, exitB, findidB;
FindnameButtonHandler FindnameHandler;
FindrankButtonHandler FindrankHandler;
ExitButtonHandler exitHandler;

private static final int WIDTH = 450;
private static final int HEIGHT = 200;

public nameid()

// Create labels
NameL = new JLabel("Enter the Name: ",
RankL = new JLabel("Enter the id#: ",

//Create text fields
NameTF = new JTextField(20);
RankTF = new JTextField(20);

//create Find Name Button
findnameB = new JButton("Find Name");
FindnameHandler = new FindnameButtonHandler();

//create Find rank button
findrankB=new JButton("Find id");
FindrankHandler = new FindrankButtonHandler();

//Create Exit Button
exitB = new JButton("Exit");
exitHandler = new ExitButtonHandler();

//Set the title of the window
setTitle("Person's name and id#");

//Get the container
Container pane = getContentPane();

//Set the layout
pane.setLayout(new GridLayout(0,2,1,1));

//Place all items created
//set the size of the windowand display it

private class FindnameButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)


private class FindrankButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)


private class ExitButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)

public static void main( String args[] )
nameid rectObject = new nameid();