0

Is there any way to change the background color of a particular cell directly by its row index and column index ?

Component comp = table.findComponentAt(row, column);
comp.setBackground(Color.RED);

I tried above but it change the background color of whole table. How to change the background color of that particular cell ?

As I have seen there are two many questions and solutions related to changing color of a cell. But I am looking for a simple solution by which I could change the color of a cell directly by its index.

Vishal Goyal
  • 193
  • 14
  • 1
    [Using Custom Renderers](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer) and [Concepts: Editors and Renderers](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender) are the places to start – MadProgrammer Jun 04 '16 at 09:28
  • 1
    [For example](http://stackoverflow.com/questions/30552644/how-do-i-color-individual-cells-of-a-jtable-based-on-the-value-in-the-cell/30553979#30553979), which I tempted to use as a duplicate close reason, and [another example](http://stackoverflow.com/questions/15538237/coloring-jtable-cells-based-on-an-array-created-by-tetris-game/15538535#15538535) – MadProgrammer Jun 04 '16 at 09:31

0 Answers0