This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a JTable that shows different information related to various dates. So the table can have 5 rows for say 05/30/2007 and then 3 rows for 04/15/2007 and then 3 rows for 03/11/2007. I want to group all rows specific to a particular date by setting the background of those rows in one color. So all 5/30/2007 rows will be blue and 04/15/2007 rows in white and 03/11/2007 rows in blue again.
How can I do this?
Joined: Jul 16, 2006
Actually I was able to do this by keeping track of the date value in my renderer, but the problem at hand is when the user starts clicking on arbitrary cells the date information kept in the renderer is no longer valid.
You probably don't want your cell renderer maintaining state. You would be better off keeping track of that kind of thing in your TableModel. The table cell rendeder can call table.getModel() [and cast the result] to access your model.