• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing background color of cell in JTable  RSS feed

 
Nasir Baig
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

I have a jTable in my application. I want to change the color (if value is positive then blue, otherwise green) of particular column.

Here is the code:


It changes the background color of the cell of 5th column. But it doesn't display any text (value).

Let me know what's wrong I am doing here.

Thanking you in advance for your help.

Nas
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make a JLabel display some text, you have to call its setText() method.
 
Nasir Baig
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...

It worked.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!