I came across the strange behavior of JTable (JDK 1.5_22):
After changing the selection in the table and under some unknown specific circumstances, JTable will call the cell renderer with "null" for the value parameter.
This will ultimately lead to a good “Null Pointer Exception” in the code of the user renderer that is not ready for such rude calls.
Here is the culpable method (JTable.java, line 5319):
public Accessible getAccessibleChild(int i) {
if (i < 0 || i >= getAccessibleChildrenCount()) {
return null;
} else {
int column = getAccessibleColumnAtIndex(i);
int row = getAccessibleRowAtIndex(i);
TableColumn aColumn = getColumnModel().getColumn(column);
TableCellRenderer renderer = aColumn.getCellRenderer();
if (renderer == null) {
Class<?> columnClass = getColumnClass(column);
renderer = getDefaultRenderer(columnClass);
}
Component component = renderer.getTableCellRendererComponent(
JTable.this, null, false, false,
row, column);
return new AccessibleJTableCell(JTable.this, row, column,
getAccessibleIndexAt(row, column));
}
}
and here the main focus is on the erroneous statement:
Component component = renderer.getTableCellRendererComponent(
JTable.this, null, false, false,
row, column);
Asking google whith "JTable getAccessibleChild 5334" was interesting: I'm not alone to meet this "feature." But there was no answer.
.
- ?