Alright this is a follow-up to my last question:
JTable: Changing cell background when a button is clicked
I can now change background color of selected cells in the JTable by using the isSelected parameter, but I can’t figure out the logic to get the cell renderer to set the backgrounds of certain cells every time it renders.
Basically I want to selected a few cells, click a button, change the background color of selected cells, and have it keep that color after I deselect the cell (without effecting the unselected cells).
This seems like such a simple problem, but I am absolutely stumped on how to do this.
As always, any input is appreciated.
You will need to store information about which cells are selected and the background that is needed. Then your CellRenderer will need to refer to that information when deciding what color to use for the background.
Basic logic for renderer: