Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Setting foreground of a table cell on date column

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I set the foreground of a cell that is
of the date column class in my renderer?
I've tried

But it doesn't seem to work.
Something else interesting...
I tried doing the following:

and nothing ever prints to std out. Any ideas why??
What am I missing?
Thanks!
[ August 21, 2003: Message edited by: Jennifer Sohl ]
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you setting this renderer on your table?
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the following:
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried something else in my renderer:
I added the following code:

Nothing ever printed out, like the column wasn't ever equal to index 9???
The same thing happens on columns of Integer type.
If the column is a String , it prints out.
Here's my model:

Here's my renderer:

Here is how I am setting the renderer:

What's going on???
Many thanks to anyone that can help!
[ August 22, 2003: Message edited by: Jennifer Sohl ]
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with this code
public class GeneralRenderer extends DefaultTableCellRenderer
{
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row, int column)
{
if(column == <Date Column No>
{
setFont(<font> ;
setBackground(<BackgroundColor> ;
setForeground(<ForegroundColor> ;
}
return this;
}
}
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with this code
public class GeneralRenderer extends DefaultTableCellRenderer
{
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row, int column)
{
if(column == <Date Column No>
{
setFont(<font> ;
setBackground(<BackgroundColor> ;
setForeground(<ForegroundColor> ;
}
return this;
}
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JTables use the most specific renderer they can... they already have a default renderer for String, Integer, Boolean, etc. so they are never going to use your renderer if you register it with the java.lang.Object class. You're going to have to set your renderer as the default renderer for the String.class, the java.util.Date.class, and anything else your renderer is providing a view for.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the help. I tried setting the default renderer for each class String, Integer and Date, and it is working now.
Funny, I've never run into that before.
Guess you learn something new every day!!
Thanks again!
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic