Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top