Swing/JTable Not Updating After Bound Data Fires Change

前端 未结 4 1741
悲哀的现实
悲哀的现实 2021-01-22 18:16

I have a JTable which is bound to my EventTracker bean, essentially a wrapper around a list which I will use as append/clear only (i.e., a simple log). Problem is, when I add en

4条回答
  •  离开以前
    2021-01-22 18:44

    Assuming your data model derives from AbstractTableModel, you can update your model explicitly and fire the appropriate update method implemented in the abstract parent. Moreover, updates must occur on the EDT, typically using invokeLater(). See also Listening for Data Changes and Firing Data Change Events.

    EventQueue.invokeLater(new Runnable() {
    
        @Override
        public void run() {
            // update model, which should fire the appropriate event
        }
    });
    

提交回复
热议问题