Changing Cell Color without changing color in other cells (Jtable)

前端 未结 2 571
无人共我
无人共我 2020-12-22 03:16

So say that we have a JTable with 31 columns and 10 rows. And I want to change the color of the 2 Column 4 row to red. And after I do that change another cell color without

2条回答
  •  眼角桃花
    2020-12-22 04:15

    You need to set the cell renderer on the column that you want it on.

    If you say that you want cell color of row 2 column 4 to be red, then you should set the renderer on the 4th column. You could even set the renderer on all columns.

    Then all you have to do is do an if-check on the row. ie. if (row == 4). But I assume you would get your values from your TestHotel.v object instead.

提交回复
热议问题