开发者

Table model in empty table

开发者 https://www.devze.com 2022-12-31 22:34 出处:网络
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

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

精彩评论

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