Here you can find the source of setHeaderIcon(JTable table, final int column, final ImageIcon icon)
public static void setHeaderIcon(JTable table, final int column, final ImageIcon icon)
//package com.java2s; //License from project: LGPL import javax.swing.*; import java.awt.*; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; public class Main { public static void setHeaderIcon(JTable table, final int column, final ImageIcon icon) { final TableCellRenderer orig = table.getTableHeader().getDefaultRenderer(); table.getTableHeader().getColumnModel().getColumn(column).setHeaderRenderer(new DefaultTableCellRenderer() { @Override//from w w w .ja v a 2 s .c om public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel com = (JLabel) orig.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); com.setHorizontalAlignment(JLabel.LEADING); // On Fedora its TRAILING; looks odd with the icon itself trailing com.setIcon(icon); return com; } }); } }