public void searchBtn_actionPerformed(ActionEvent e) {
String searchfilmName = searchtxtbox.getText().toLowerCase();
boolean found = false;
try {
store.setFileName("FilmDatabase.jds");
store.setUserName("odeon");
store.setPassword("1234");
table.setStoreName("FILMTABLE");
table.setStore(store);
table.open();
table.setSort(new SortDescriptor(new String[] {"FILMID"}));
table.first();
while (found != false) {
table.getInt("FILMID");
String filmName;
filmName = table.getString("FILMNAME").toLowerCase();
if (filmName.equals(searchfilmName.toLowerCase())) {
displayInfo();
found = true;
break;
}
else {
Frame4 form = new Frame4();
form.setSize(500, 550);
form.setVisible(true);
this.hide();
}
table.next();
}
} catch (DataSetException dse) {
dse.printStackTrace();
} finally {
try {
store.close();
table.close();
} catch (DataSetException dse) {
dse.printStackTrace();
}
}
}
public void displayInfo() {
Frame2 form = new Frame2();
form.setSize(500,550);
form.setVisible(true);
this.hide();
}
Sorry for posting the same program again but I'm having a diff problem with it now :/. Ok, this program is supposed to allow a user to enter a movie name and search for it. Once they've clicked the button, the program should then check the database for that movie, if it's not there then go to frame4(error page), if it's found then open frame2.
Now, when I put table.inbounds() in the while statement. The program opens the frame if the movie is found, however, it also opens frames to the error page (frame 4) for any film that is not what they were searching for after the corrent film in the collumn.
Meaning that if I search for "hitch" which is like number 4 in the table then it will open frame 2 and then open about 4 frame4 (error page)
So, I decided to use the boolean found so that it would end if the movie was found. For some reason which I don't know, when I hit search NO windows open, even if the film is in the database or not...
I have no idea why no frames open up...confused :/.
Any help would be much appreciated.