Pessoal quero centralizar por exemplo só a coluna 1.
Ele até centraliza, mas daí perco as outras renderizações.
Alguma idéia !!
public class CorLinhaCondicao implements TableCellRenderer {
private int st=0;
private int lih;
public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();
@Override
public final Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column) {
Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Color foreground=Color.BLACK;
Color background=null;
lih=table.convertRowIndexToModel(row);
DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();
centralizado.setHorizontalAlignment(SwingConstants.CENTER);
if(isSelected){
foreground = Color.BLACK;
background = Color.WHITE;
table.getColumnModel().getColumn(1).setCellRenderer(centralizado);
}else {
//Email Enviado ********
if ((int)table.getModel().getValueAt(lih,7)==1) {
foreground = Color.BLACK;
background = new Color(0,153,0);
}
//Enviar Email**********
if ((int)table.getModel().getValueAt(lih,7)==4) {
foreground = Color.BLACK;
background = new Color(255,204,0);
}
//Empresa Encerrada************
if ((int)table.getModel().getValueAt(lih,7)==3) {
foreground = Color.WHITE;
background = new Color(51,51,51);
}
//Email Invalido
if ((int)table.getModel().getValueAt(lih,7)==2) {
foreground = Color.WHITE;
background = new Color(255,51,51);
}
//Vsita Agendada*********
if ((int)table.getModel().getValueAt(lih,7)==5) {
foreground = Color.WHITE;
background = new Color(51,153,255);
}
//Retorno Contato*********
if ((int)table.getModel().getValueAt(lih,7)==6) {
foreground = Color.WHITE;
background = new Color(153,0,153);
}
}
renderer.setForeground(foreground);
renderer.setBackground(background);
return renderer;