2017-02-14 111 views
0
class CustomTableRenderer extends 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); 
      String s = table.getModel().getValueAt(row,12).toString();      
      if(s.equals("Filled") && column == 12) 
      { 
       setForeground(Color.RED); 


       System.out.println("Inside " + s + column); 
      } 

     return c; 
    }} 

使用上面的代码,所有列chaging的颜色,我想根据值更改单列。基于单元值的Jtable单元格字体颜色

回答

0

忽略上述问题。我也得到了同样的答案。