Posted by mendi
on November 3, 2010 at 3:17 AM PDT
I have a JTable from which I need to insert data to a database. I need to implement the functionality of data adding like this:
User will fill in all (or some) cells in a row, and when the focus is passed to another row (I need to detect it) the data will be collected from all the cells of that row and be inserted in the database. I tried to write my own TableModel which implements the TableModelListener interface and use its tableChanged(TableModelEvent e) method, but it's triggered for each change in a single cell. I need to detect changes between rows and if any of the cells has changed then make the update to the database, if none of the cells has changed do nothing. I also tried something with ListSelectionListener, which helps to detect the selections in JTable rows, but got stuck somewhere and couldn't make it work as I exactly want.
It'll be exactly like adding data in a table of MS Access. Any ideas how to make it work???
I'd appreciate it very much if somebody could help me.
Thanks in advance!