Here you can find the source of createDefaultTableCellRenderer()
private static DefaultTableCellRenderer createDefaultTableCellRenderer()
//package com.java2s; import java.awt.Component; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.JTableHeader; public class Main { private static DefaultTableCellRenderer createDefaultTableCellRenderer() { DefaultTableCellRenderer label = new DefaultTableCellRenderer() { private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (table != null) { JTableHeader header = table.getTableHeader(); if (header != null) { setForeground(header.getForeground()); setBackground(header.getBackground()); setFont(header.getFont()); }/* w ww .jav a 2 s. c om*/ } setText((value == null) ? "" : value.toString()); setBorder(UIManager.getBorder("TableHeader.cellBorder")); return this; } }; label.setHorizontalAlignment(JLabel.CENTER); return label; } }