Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TableCellRenderer

 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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?

Thanks!
 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Brian Cole
Author
Ranch Hand
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic