Table model in empty table
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?
开发者_如何学JAVAThanks in advance!
I usually handle such model-view conversion anomalies by Using Custom Renderers. For example:
setText((value == null) ? "" : formatter.format(value));
精彩评论