When I select a row in a JTable, my JTable doesn’t get updated anymore. When I don’t select a row, the code beneath works as expected. A row is added to the JTable.
@Override public void update (Observable arg0, Object arg1) { if (arg0 instanceof Logger) { LogItem last = systemController.logController.getLog().getLastLogItem(); this.history.add(last); this.logTableModel.addItem(last); this.logTable.tableChanged(new TableModelEvent(this.logTableModel)); ((DefaultTableModel)this.logTable.getModel()).fireTableStructureChanged(); this.logTable.repaint(); this.logTable.doLayout(); } }
When I close the window and reopen it, I can see the new row.
Can someone explain me why, after selecting a row, I don’t see any updates in the JTable anymore?
Is the update() call happening in the Swing event thread? If not the code will need to be wrapped with something like: