This works for me. Here is my SSCCE :
import java.awt.*; import javax.swing.*; import javax.swing.table.*; public class TableHeaderBackground { public static void main(String[] args) { Integer[][] data = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; String[] cols = {"A", "B", "C"}; JTable table = new JTable(data, cols); JTableHeader header = table.getTableHeader(); header.setBackground(Color.black); header.setForeground(Color.yellow); JOptionPane.showMessageDialog(null, new JScrollPane(table)); } }
If this does not help you, I suggest you create and publish your own SSCCE so that we can see what is wrong.
Hovercraft full of eels
source share