tags:

views:

49

answers:

3

I don't want to set the background color for all the cells in the jtable, just the ones I choose. How do i go about doing this?

+3  A: 

you need to use a custom renderer

objects
Isn't there an easier faster way to do this?
vamsi
unfortunately not. The renderer is what handles painting each individual table cell
objects
theres an example and some discussion here http://www.jguru.com/faq/view.jsp?EID=53764
objects
+2  A: 

You might find the concept presented in Table Row Renderering easier to implement. Maybe keep a Set of Points (representing a cell you want to color). Or maybe even a Map of Points and Colors.

camickr
A: 

You'll need to create a custom CellRenderer and call it in your custom JTable's getCellRenderer(int col, int rol) method.

See http://self-reference.com/tech/swing.html for a good example.

vdoma