Рисовальщик для JTable
Есть JTable 1 столбец boolean, 1 Date и несколько String. Написал рендерер - String раскрашен, а boolean и Date нет.
Вот код:
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
/**
*
* @author ssi
*/
public class Celrend extends JLabel implements TableCellRenderer{
private static final long serialVersionUID = 900550195481093674L;
Font f = new Font("Verdana", Font.ITALIC, 14);
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel component = new JLabel(value.toString());
component.setFont(table.getFont());
if(column==0){component.setOpaque(true);component.setText(Integer.toString(row));component.setBackground(Color.WHITE);}
if(column==1){component.setOpaque(true);component.setForeground(Color.RED);component.setBackground(Color.WHITE);}
if(column==3){component.setOpaque(true);component.setForeground(Color.RED);component.setBackground(Color.WHITE);}
if(column==13){component.setOpaque(true);component.setForeground(Color.MAGENTA);component.setBackground(Color.WHITE);}
if(table.getValueAt(row, 11).equals("-")){ component.setOpaque(true);component.setFont(f);component.setBackground(Color.WHITE); }
if(isSelected){
component.setOpaque(true);
component.setBackground(new Color(249, 249, 196));
// component.setForeground(Color.BLUE);
}
if(hasFocus){
component.setOpaque(true);
component.setBackground(new Color(196, 249, 205));
// component.setForeground(Color.BLUE);
}
return component;
}
}
Подскажите, что не так делаю.
Источник: Stack Overflow на русском