0

I am kind of a newbie in Java, so my question is. If for example I have a JTable which represents a 2D array of Color

Color [][] array = new ...

So then when I run the JFrame it shows enter image description here

So how do I color it?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Phil_Charly
  • 137
  • 13
  • This [answer](http://stackoverflow.com/questions/14563799/jtable-cellrenderer-changes-backgroundcolor-of-cells-while-running/14565614#14565614) will help you. – Amarnath Jul 03 '13 at 15:21

1 Answers1

4

You can attach a cellrenderer to your JTable and adjust the color with it: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer

Horstinator
  • 548
  • 1
  • 5
  • 18
  • So it is necessary to use a renderrer function – Phil_Charly Jul 02 '13 at 19:51
  • @Phil_Charly not a function, a instance of a implementation of [TableCellRenderer](http://docs.oracle.com/javase/6/docs/api/javax/swing/table/TableCellRenderer.html). There you can create a component which will be displayed in the cell of the table. – Horstinator Jul 03 '13 at 07:59