Вот как я сделал это для проверки только для числовых данных. Он будет окрашен в красный цвет при сбое проверки.
column.setCellEditor(new DefaultCellEditor(new JTextField()){
@Override
public Object getCellEditorValue() {
// throws exception if parsing failes, and it's catched on stopCellEditing
return Integer.parseInt((String) super.getCellEditorValue());
}
@Override
public boolean stopCellEditing() {
boolean result = false;
try{
result = super.stopCellEditing();
((JTextField)getComponent()).setBackground(Color.WHITE);
}catch (NumberFormatException e) {
((JTextField)getComponent()).setBackground(Color.RED);
result = false;
}
return result;
}
@Override
public boolean isCellEditable(EventObject anEvent) {
// reset color when begin editing
((JTextField)getComponent()).setBackground(Color.WHITE);
return super.isCellEditable(anEvent);
}
});