0

I have to make a JTable which partely has colors and partely has to display strings.

Here is a quick drawing:

I suck at drawing

The first colonm contains strings while the rest of the colomns contain colors. the header contains only strings.

I defined the header (which is not really important for this question) as an array of strings and I defined the data of the table as an Object[][] data

When I tried to do something like data = {"Room 1", new color(242, 242, 242)}; the compilor gives me: Type mismatch: cannot convert from Color to Object[]

How can I display the Colors?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
BRHSM
  • 854
  • 3
  • 13
  • 48
  • 1
    refer this , http://www.codejava.net/java-se/swing/jtable-column-header-custom-renderer-examples – Vishal Gajera Mar 30 '16 at 07:38
  • @vishalgajera That's about headers. I want to change colors in individual cells? – BRHSM Mar 30 '16 at 07:42
  • 3
    Yes, for [example](http://stackoverflow.com/questions/34635888/switching-color-of-buttons-in-a-jtable/34642577#34642577), [example](http://stackoverflow.com/questions/30552644/how-do-i-color-individual-cells-of-a-jtable-based-on-the-value-in-the-cell/30553979#30553979), [example](http://stackoverflow.com/questions/15286929/jtable-valuechanged-then-change-cell-color/15286979#15286979), [example](http://stackoverflow.com/questions/16409494/setting-the-color-for-a-jcheckbox-cell-in-a-jtable/16409726#16409726), – MadProgrammer Mar 30 '16 at 07:53
  • 2
    [example](http://stackoverflow.com/questions/16772158/change-the-color-of-specific-rows-in-my-jtable/16772469#16772469) ... you get the idea – MadProgrammer Mar 30 '16 at 07:54

0 Answers0