I'm using a JTable and I need to, when a button is pressed, change a certain cell's color. The whole table's background color is gray and it's cells display ImageIcons. I got the Icons part up and running but I'm having great trouble on changing a cell's color - so far I've only managed to change a whole column and that's not what I need. I've been Googling for solutions for 2 hours and reading it's results for 4, so I'm getting pretty desperate here :(
For doing what I stated, what I have so far for the button's mousepressed event is:
DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
jTable1.getColumnModel().getColumn(3).setCellRenderer( dtcr );
By the way, after I change the background color of a column I can't properly move an icon on to it (but that's probably because it changes the column's DefaultRenderer, I can change it back afterwards, right?). I believe, since I'm using ImageIcons on the cells I could create icons of the background color I desire and use setValueAt to change the cell's appearance -is this a solution? But anyway, I haven't gotten the icon to fully cover the cell yet...
Thanx in advance! :)