in src/main/groovy/groovy/swing/MyTableModel.java [95:121]
public void setValueAt(Object value, int row, int col) {
if (log.isLoggable(Level.FINE)) {
log.fine(
"Setting value at " + row + "," + col + " to " + value + " (an instance of " + value.getClass() + ")");
}
if (data[0][col] instanceof Integer && !(value instanceof Integer)) {
//With JFC/Swing 1.1 and JDK 1.2, we need to create
//an Integer from the value; otherwise, the column
//switches to contain Strings. Starting with v 1.3,
//the table automatically converts value to an Integer,
//so you only need the code in the 'else' part of this
//'if' block.
//XXX: See TableEditDemo.java for a better solution!!!
try {
data[row][col] = Integer.valueOf(value.toString());
fireTableCellUpdated(row, col);
}
catch (NumberFormatException e) {
log.log(Level.SEVERE, "The \"" + getColumnName(col) + "\" column accepts only integer values.");
}
}
else {
data[row][col] = value;
fireTableCellUpdated(row, col);
}
}