0

I have a View class that is an Observer of a Model. The view class has an Update() method which receives an array whenever that array is updated. I have verified the array is received, after which a new table model is created and applied to the JTable using the setModel() method.

The problem is, the table view is not visibly refreshed until the controller's file processing loop ends.

My goal is to have the table view be updated in realtime (dynamically), whenever its underlying data model is updated.

clearlight
  • 12,255
  • 11
  • 57
  • 75
  • 2
    Update the table's `TableModel` on the [event dispatch thread](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html), and the listening `JTable` will update itself in response. – trashgod Dec 29 '16 at 23:06
  • @trashgod - To further clarify, what you're saying is table refresh is implicitly triggered in response to the model update, but that update is blocked by the action handler's thread. A common type of problem. Same kind of thing occurs with tables in iOS – clearlight Jan 02 '17 at 22:29
  • 1
    @HotAppleCyber: Good point; a `SwingWorker`, for [example](http://stackoverflow.com/a/25526869/230513), may be warranted. – trashgod Jan 03 '17 at 00:37
  • Good point (and nice solution, btw :) ) – clearlight Jan 03 '17 at 00:40

0 Answers0