Cell Renderer for JTable - coloured rows

后端 未结 4 1918
太阳男子
太阳男子 2021-01-23 09:58

I\'ve been looking around for a solution to this and I can\'t make head nor tail from various places of how to get my table to do coloured rows without asking my own question.

4条回答
  •  旧巷少年郎
    2021-01-23 10:32

    I simply want each row to be highlighted in either green, yellow or red depending on the value of a separate variable (not displayed in the table).

    Renderers work on data in the table. That is components can only paint themselves when they have all the information needed to do the job.

    So somehow you need to add the information to the table. This might be done be adding a 4th column that is hidden. Then the table still has access to the information required.

    Then maybe you can use the suggestion in Table Row Renderering.

提交回复
热议问题