comp101
07-29-2009, 05:53 PM
I have created an Address Book using a random access file that allows me to save records and cycle between records with buttons that go to the first entry, last entry, previous entry, and next entry.
I need help in creating an update and search method. The search button is my main priority. I want the user to be able to search the file by entering a word in a textfield and having the option of whether to match it with a record name, street, city, state, or zip. I am very stuck now.
Here is the actionPerformed section of my code in the Search class so far with the only focus on the user being able to try and compare names in the record:
**When the OK button is pressed, I want the comparison to happen**
public void actionPerformed(ActionEvent e) {
if (e.getSource()==jcbsearch){
search();
}
else if (e.getSource()==jbtok){
}
else if (e.getSource() == jbtcancel){
dispose();
}
}
public void search(){
if(jcbsearch.getSelectedItem()=="Name"){
Search frame2 = new Search(1);
frame2.pack();
frame2.setTitle("Search");
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setLocationRelativeTo(null);
frame2.setVisible(true);
}
}
I need help in creating an update and search method. The search button is my main priority. I want the user to be able to search the file by entering a word in a textfield and having the option of whether to match it with a record name, street, city, state, or zip. I am very stuck now.
Here is the actionPerformed section of my code in the Search class so far with the only focus on the user being able to try and compare names in the record:
**When the OK button is pressed, I want the comparison to happen**
public void actionPerformed(ActionEvent e) {
if (e.getSource()==jcbsearch){
search();
}
else if (e.getSource()==jbtok){
}
else if (e.getSource() == jbtcancel){
dispose();
}
}
public void search(){
if(jcbsearch.getSelectedItem()=="Name"){
Search frame2 = new Search(1);
frame2.pack();
frame2.setTitle("Search");
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setLocationRelativeTo(null);
frame2.setVisible(true);
}
}