Your problem is when you add a new column, you need to extend your types
variable, because that holds values only for 'default' columns, and when getColumnClass()
called for new columns that throws ArrayIndexOutOfBoundsException
.
EDIT:
Example of extending your model, just override addColumn()
method like next:
@Override
public void addColumn(Object columnName) {
Class[] temp = new Class[types.length +1];
System.arraycopy(types, 0, temp, 0, types.length);
temp[types.length] = Double.class;
types = temp;
super.addColumn(columnName);
}
Also examine @mKorbel comment.