• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TableCellRenderer

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic