且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何正确使用自定义渲染器绘制JTable中的特定单元格?

更新时间:2023-12-03 12:10:04

中添加else子句,如果

if ((row == 0) && (column == 0)) {
    d.setBackground(new java.awt.Color(255, 72, 72));
}
else {
    d.setBackground(Color.WHITE);
}

请记住,相同的渲染器实例用于绘制所有单元格。

Remember that the same renderer instance is used to paint all the cells.