posted 8 years ago
What I've done: I have created a GUI using NetBeans (8.0.2) to store details about Car. The GUI has a jTable where the details of the cars are stored such as; CarReg Number, Car Make and Car price. It works by entering all the details of the Car in three separate jTextFields, once the details are entered the "Add to table" button is selected and it's added to the jTable. There is another jTextfield which the user uses to search for a car according to the price entered. E.g. If price £2000 is entered into the jTextfield and "Search Car" button is pressed then it will return a jOptionPane will the matched price and the Car Make ("Yes, a Ford at price £2000 has been found") otherwise if it did not find the price an error message will appear.
The Problem, If there are two rows in the jTable with different car details E.g:
ROW 1 DETAILS CAR REG: BD51SMR CAR MAKE: FORD PRICE: £2000
ROW 2 DETAILS CAR REG: FS45BKY CAR MAKE: AUDI PRICE: £1000
And you want to search for a car at price £2000 (Row 1) and select "Search Cars" button it will display the following in a jOptionpane: ("Yes, a Ford at price £2000 has been found"). Now if you want to search for a car at price £1000 (Row 2) and select "Search Cars" button it will display the following in a jOptionpane: ("Yes, a Ford at price £1000 has been found"). The above is the error, it will find the matched price but the make of the car still stays as the first column value "Ford" and should have displayed ("Yes, a AUDI at price £2000 has been found").
I'm not quite sure what's wrong with this.
My code: