samwell
samwell

Reputation: 2797

How to prevent a cell from being highlighted when selected?

I have the first column of my AbstractTableModel designated to have a checkbox. But when I click on the checkbox the whole row gets selected. I don't mind this, but I was wondering if there was a way to prevent the first column from being highlighted?

Upvotes: 1

Views: 98

Answers (1)

trashgod
trashgod

Reputation: 205875

The DefaultTableCellRenderer examines the isSelected parameter passed to the getTableCellRendererComponent() method and sets the selection color accordingly. To affect all conforming renderers, You can make the selection color equal to the background color using the relevant UIManager keys, Table.background and Table.selectionBackground.

UIManager.put("Table.selectionBackground", UIManager.get("Table.background"));

In a acustom renderer, you can specify the same color irrespective of isSelected.

Upvotes: 1

Related Questions