JTable model getColumnClass() problem

Im extending DefaultTableModel with a class called MyTableModel. In this class I define the method getColumnClass() so that boolean values will be rendered as Check boxes

public Class getColumnClass(int c) {

return getValueAt(0, c).getClass();

}

the problem is, I get NullPointerExceptions when loading my model data because in some cases getValueAt(0, c) is null

I can just null check in getColumnClass, but then i dont know what to return

Any swing pros know how to overcome this problem

[534 byte] By [jes1789a] at [2007-10-2 11:35:38]
# 1
on second thought, i guess i would be safe in just returning (new String()).getClass() when its null
jes1789a at 2007-7-13 5:06:29 > top of Java-index,Desktop,Core GUI APIs...
# 2

> on second thought, i guess i would be safe in just returning (new String()).getClass() when its null

This doesn't make sense. This method is only invoked at a column level, not row and column. So if the first entry in you column is null then all the rows in this column will be renderered as Strings, instead of check boxes.

This is a problem with your data and only you can solve the problem.

camickra at 2007-7-13 5:06:30 > top of Java-index,Desktop,Core GUI APIs...