A Java Swing user interface I am working on which makes extensive use of a custom
JTableModel implementation was failing. In certain instances when my data structure changes, it purges empty cells. If the cursor was left in these cells while this was taking place, the table would become unresponsive, often requiring an application restart to fix.
Watch for issues with
setValueAt
, which in some cases can be called with invalid values. In particular if the cursor is editing a field, the table is not refreshed until the edit focus leaves the widget even if you try to force it with
validate()
calls. In my instance the ideal fix was to add checks and do nothing instead of throwing exceptions.
With
getValueAt
, some table widget types choked on my default of null, which I was returning for invalid cells. Using an empty string instead of null for these invalid cells fixed this problem.