This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
How do I know what record to update? Yes, I realize this depends on how I design everything else. I'm using an algorithm based on position in the file for the recNo. I read strings out of the file, and populate the table model. Right now I am not putting the recNo as a column in the table model. My GUI uses a text box to get the customer number, and based on the line in the JTable that is highlighted, will want to update the database file that the record is now reserved. But I lost the recNo to use. I thought about building a map of JTable row to database recNo, but then wasn't sure how to keep that updated if I allow the columns to be sorted. Could be cheap and remove column sorting. Or I could add recNo as a column in the JTable, and use that, sorta like how the upc value is used in the "Denny DVD" example.
It's better to have record number on client side. It saves from lot of work. Using JTable row number may not be a good idea. You could manage row number in sorting but what if some user deletes a record? Add a hidden column for record number in data display table.
Joined: Jul 23, 2003
I looked for how to hide a column, but could not see a good way. Would you be able to provide an example? Thanks!