TableCellRenderer[] columnRenderers = new TableCellRenderer[columnCount];
for (int columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
tableColumns[columnIndex] = columnModel.getColumn(columnIndex);
TableCellRenderer renderer = tableColumns[columnIndex].getCellRenderer();
if (renderer == null) {
Class columnClass = model.getColumnClass(tableColumns[columnIndex].getModelIndex());
renderer = getDefaultRenderer(columnClass);
if (renderer == null) {
renderer = DEFAULT_TABLE_CELL_RENDERER;
}
}
columnRenderers[columnIndex] = renderer;
}
if (isHeaderVisible()) {
for (int columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
int modelColumnIndex = tableColumns[columnIndex].getModelIndex();
Object headerValue = tableColumns[columnIndex].getHeaderValue();
if (headerValue == null) {
headerValue = model.getColumnName(modelColumnIndex);
}
TableCellRenderer headerRenderer = tableColumns[columnIndex].getHeaderRenderer();
if (headerRenderer == null) {
headerRenderer = defaultHeaderRenderer;
if (headerRenderer == null) {
headerRenderer = DEFAULT_TABLE_CELL_RENDERER;
}
}
Component renderedComponent
= headerRenderer.getTableCellRendererComponent(this, headerValue, modelColumnIndex, HEADER_ROW);
if (renderedComponent == null) {
renderedComponent = new Label();
}
add(renderedComponent);
}