Click to See Complete Forum and Search --> : How to set the background of a cell of a JTable


ramu
August 19th, 1999, 01:15 AM
Hai friends,
I want to set the background color of some cells( not selected cells) of the JTable. How to do this?

from
Ramu

I a

unicman
August 22nd, 1999, 11:17 AM
If the color of all the cells the problem is very simple, just set its background color and possibly 'setOpaque(true)'.

If u want diff color for each cell, u will need to keep the color of cell alongwith the cell value. And creating a simple CellRenderer will show the background color of that cell to specified color. This cell renderer can be just a JLabel having code to set the text (value of cell) and the background color (color of cell). Do setOpaque(true) so that JLabel will paint background.

- UnicMan