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: ",
SwingConstants.RIGHT);
RankL = new JLabel("Enter the id#: ",
SwingConstants.RIGHT);


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



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



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



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

//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
pane.add(NameL);
pane.add(NameTF);
pane.add(RankL);
pane.add(RankTF);
pane.add(findnameB);
pane.add(findrankB);
pane.add(exitB);
//set the size of the windowand display it
setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

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)
{
System.exit(0);
}
}

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