wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes TableCellRenderer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TableCellRenderer" Watch "TableCellRenderer" New topic
Author

TableCellRenderer

Dalia Sultana
Ranch Hand

Joined: Jul 16, 2006
Posts: 42
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

Joined: Jul 16, 2006
Posts: 42
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

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TableCellRenderer