• Post Reply Bookmark Topic Watch Topic
  • New Topic

stopCellEditing() and NullPointerEx  RSS feed

 
Duane Riech
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me why I'm getting a NullPointerException on this piece of code?

private void IngrstopAllCellEditing() {

for( int i = 0; i < IngredientDataModel.getRowCount(); i++ ) {
for( int j = 0; j < IngredientDataModel.getColumnCount(); j++ ) {
javax.swing.table.TableCellEditor editor =
IngredientTable.getCellEditor(i, j);
System.out.println(" row <" + i + "> column <" + j + ">" );
try {
if ( editor != null )
editor.stopCellEditing();
} /* ...end of try statement... */
catch( NullPointerException ex ) {
System.out.println(" Nullpointer - row <" + i + "> column <" + j + ">" );
}
} /* ...end of outer for loop... */
} /* ...end of outer for loop... */
} /* ...end of method IngrstopAllCellEditing()... */

My JTable displays the last column of data, as defined by my
TableModel, columncount = 4.

row <0> column <0>
row <0> column <1>
Nullpointer - row <0> column <1>
row <0> column <2>
Nullpointer - row <0> column <2>
row <0> column <3>
Nullpointer - row <0> column <3>
row <1> column <0>
row <1> column <1>
Nullpointer - row <1> column <1>
row <1> column <2>
Nullpointer - row <1> column <2>
row <1> column <3>
Nullpointer - row <1> column <3>
row <2> column <0>
row <2> column <1>
Nullpointer - row <2> column <1>
row <2> column <2>
Nullpointer - row <2> column <2>
row <2> column <3>
Nullpointer - row <2> column <3>
row <3> column <0>
row <3> column <1>
Nullpointer - row <3> column <1>
row <3> column <2>
Nullpointer - row <3> column <2>
row <3> column <3>
Nullpointer - row <3> column <3>
row <4> column <0>
row <4> column <1>
Nullpointer - row <4> column <1>
row <4> column <2>
Nullpointer - row <4> column <2>
row <4> column <3>
Nullpointer - row <4> column <3>
row <5> column <0>
row <5> column <1>
Nullpointer - row <5> column <1>
row <5> column <2>
Nullpointer - row <5> column <2>
row <5> column <3>
Nullpointer - row <5> column <3>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!