views:

36

answers:

1

I am creating a Java Swing application which displays a window with a table where the user can insert or delete selected elements stored in an array. For this table I have created a table model class extending the DefaultTableModel class. The problem arises when all the elements have been deleted from the table, as a null pointer exception is thrown. Does anyone know a quick solution to this problem?

Thanks in advance!

+1  A: 

I usually handle such model-view conversion anomalies by Using Custom Renderers. For example:

setText((value == null) ? "" : formatter.format(value));
trashgod