需要帮助JTable,改变细胞颜色

时间:2016-07-15 15:20:30

标签: java swing jtable tablecellrenderer

public static void setCellRenderer(JTable CustDtlsTbl) {
    TableCellRenderer cellRenderer = createCellRenderer();
    CustDtlsTbl.setDefaultRenderer(Object.class, cellRenderer);
}

...

public static TableCellRenderer createCellRenderer() {
return new DefaultTableCellRenderer() {
    @Override
    public Component getTableCellRendererComponent(JTable CustDtlsTbl, Object value, boolean isSelected, boolean hasFocus, int row, int column) {  
        Component cell =  super.getTableCellRendererComponent(CustDtlsTbl, value, isSelected, hasFocus, row, column); 

当值为负时,如何修改上述两种方法来改变单元格颜色?

0 个答案:

没有答案