That\'s a question really similar to this previous post of mine. I need to customize some cell of a JTable, in a way that they would look like a table header cell. I\'m usin
The appearance of the default table header for a typical Look & Feel is provided by an instance of sun.swing.table.DefaultTableCellHeaderRenderer. You can obtain a copy as follows:
class HeaderRenderer implements TableCellRenderer {
TableCellRenderer renderer;
public HeaderRenderer(JTable table) {
renderer = table.getTableHeader().getDefaultRenderer();
}
@Override
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int col) {
return renderer.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, col);
}
}
and you can install it in the usual way for a given column's type token:
table.setDefaultRenderer(SomeObject.class, new HeaderRenderer(table));