Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Color of JTable cell texts

 
Csaba Kassitzky
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

Does anyone know how to set the forground color of a certain cell in a JTable?

Thanks!

Csaba
 
Brian Cole
Author
Ranch Hand
Posts: 924
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the default renderers and your
table model is returns a String for that cell,
you can have it instead return

<html><font color=red>whatever the old value was

Otherwise you need to use a custom table cell
renderer. See this tutorial.
 
Brian Cole
Author
Ranch Hand
Posts: 924
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I guess if your table model returns something
other than the a String, it can just return

"<html><font color=red>"+theOldValue
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!