Unless you have specifically set a dedicated Country
editor for that column, your test value instanceof Country
is likely to be false. Most likely value
is actually a String
. Your setValueAt
method should rather look like this:
@Override
public void setValueAt(Object value, int rowIndex, int columnIndex)
{
if(value instanceof String)
{
Country country = countries.get(rowIndex);
String newValue = (String) value;
switch (columnIndex)
{
case 2:
country.setCountryName(newValue); break;
case 3:
country.setCountryCode(newValue); break;
}
fireTableCellUpdated(rowIndex, columnIndex);
}
}
Of course, if the type of countryName and countryCode is not String
, you should return appropriate values for the method TableModel.getColumnClass
and test for appropriate types in setValueAt