I did this just the other day! I would suggest using the DefaultTableModel, you'll have an easier time with it. This was my code: It will be somewhat different, but overall it should look similar. Again, I really think you should use the DefaultTableModel instead. Using an extension of a DefaultTableModel, it then loads each filename preceded by a Boolean and followed by a blank string.
When I click on an action button "Scan", it loops through the rows from the table model and if it is "checked", it scans the file. Each time it changes pages in the scan, it calls a method "change" in the frame holding the table with the filename as an argument. The method looks up the fileName in the model and does a tablemodel.
Since I am using setValueAt on a DefaultTableModel and haven't overridden any methods, I expect to see the value in the 3rd column ticking away 2 of 5, 3 of 5, 4 of 5, etc. After all files have been processed, the last of the values shows up for all rows simultaneously like "3 of 3" and "5 of 5" showing me that I have been setting the values.
What's missing is the changing of that cell on the screen in real-time. I've tried fireTableDataChanged , revalidate on the table, etc. I can find no reason why the JTable should not be showing me the "progress" as I loop through the rows. Edited by Reverend Jim: Fixed formatting 0 10 Years Ago Swing is a single-threaded event model.
If you are executing the code that updates the table in a button action listener then you are essentially "holding-up" processing other UI events like repaints, table updates, etc.
If you want the table to update over the course of a long running process you will need to perform that processing in a separate thread and push UI updates onto the event dispatch thread. This tutorial may help: I finally understand what's been bothering me in so many cases! Took me about 10 minutes to fix my code so it does precisely what I wanted. This link on single threaded swing should be advice to all with questions about non-responsiveness of GUI's to update events!
This topic has been dead for over six months. Start a new discussion instead. Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.