当数据在另一个数据之后时,Java表行会更改颜色

时间:2016-06-13 15:02:37

标签: java colors render

当数据在另一个数据之后时,为什么颜色不会改变。所有行都变黄了。我哪里错了?

try {
        dataFattura = format.parse(tfDataFt.getText());
    } catch (ParseException ex) {
        Logger.getLogger(FatturaClientiScheda.class.getName()).log(Level.SEVERE, null, ex);
    }
    tabella.setDefaultRenderer(Object.class, new DefaultTableCellRenderer(){
        @Override
        public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row, int col){
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
            try {
                dataFormulario = format.parse((String) model.getValueAt(row, 1));
            } catch (ParseException ex) {
                Logger.getLogger(FatturaClientiScheda.class.getName()).log(Level.SEVERE, null, ex);
            }
            if (dataFormulario.after(dataFattura))
            {
                setBackground(Color.yellow);
            }
          return this;  
        } 
    });

0 个答案:

没有答案