How can I prevent cell highlighting in a JTable?

Scott Stanchfield

The easiest way to accomplish this is to use a custom cell renderer that doesn't paint a background.

Search the Swing FAQ for "TableCellRenderer"; there are many FAQs about how to create one. If you create a table cell renderer that uses a label (or subclasses DefaultTableCellRenderer), all you need to do is call


in your getTableCellRendererComponent() method.