开发者

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜