我正在使用JXTreeTable
来制作树表结构,现在我想动态更改特定单元格的颜色。如何改变单元格的颜色?
我发现这段代码可以改变颜色,但这不起作用。
这里是代码:
leftTree.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
if(Integer.parseInt(rowvalue[0])==row && column==0) {
c.setBackground(Color.red);
}
return c;
}
});
最佳答案
使用荧光笔。
addHighlighter(new ColorHighlighter());
关于java - 如何动态更改 JXTreeTable 中特定单元格的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12107545/