It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes Updating data in the JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Updating data in the JTable" Watch "Updating data in the JTable" New topic

Updating data in the JTable

Flora Ng

Joined: Jul 05, 2001
Posts: 11
How can I update the cell values in the JTable?
I use the AbstractTableModel class and the values are in the form of Object array.
Bob Hendry

Joined: Sep 21, 2000
Posts: 19
Not an easy thing. You have to get the rows that have been added or changed and build the SQL to insert or update them in the database.
Use listeners to determine "what" has changed. Loop through the rows in the table model and issue the appropriate SQL
What you want to do is not an easy task........
Nathanael Ulrick

Joined: Jul 17, 2001
Posts: 22
I'm not sure whether Flora wants to use SQL. If she already knows what's changed, then it's simply a matter of updating the appropriate Object in the array, then calling:
yourtablemodel.fireTableCellUpdated(row, column)
I agree. Here's the link:
subject: Updating data in the JTable
It's not a secret anymore!