【问题标题】:Jtable cell font color based on cell value基于单元格值的Jtable单元格字体颜色
【发布时间】:2017-02-14 23:29:03
【问题描述】:
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;
    }}

使用上面的代码,改变所有列的颜色,我想根据值更改单个列。

【问题讨论】:

    标签: jtable


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-08
      • 2012-10-03
      • 1970-01-01
      • 2015-11-29
      • 2018-02-13
      • 1970-01-01
      • 1970-01-01
      • 2020-10-24
      相关资源
      最近更新 更多