I have a JTable that needs cell validation for the cells where the user can input text. When a user enters invalid text the border of the cell turns red.
I've managed to get this working associating a two dimension array to flag if each cell has errors or not.
The problem is that the user must be able to reorder the table (by column). I have to store the error flag in the table model, not separatly. Anyone has ideas how to do this?
Also consider a custom TableCellEditor
, seen here and below. Adding an InputVerifier
, as shown here, is a good alternative.
As the user must be able to reorder the table by column:
JTable
provides methods that convert from model coordinates to view coordinates —convertColumnIndexToView
andconvertRowIndexToView
— and that convert from view coordinates to model coordinates —convertColumnIndexToModel
andconvertRowIndexToModel
.