Grande Mantu! :lol:
Depois de horas apanhando pra JTable olhei pro meu ColorCellRenderer e veio a luz!
private int row = -1;
private Color color;
public ColorCellRenderer(Color color, int row){
super();
this.color = color;
this.row = row;
}
public void getTableCell..(params..){
...
if(this.color != null && this.row != -1){
if(this.row == row){
this.setBackground( this.color );
}
}
}
Usage:
this.table.getColumnModel().getColumn(2).setCellRenderer(new ColorCellRenderer(Color.YELLOW,0));
//Coluna 2 , Linha 0
Perfeito! Valeu! :thumbup:
[up]
Nao funciona em multiplas linhas
this.table.setEditableCells(editableCells);
for(int i = 0; i<this.table.getColumnCount(); i++){
if(!CheckBoxRenderer.class.isAssignableFrom(this.table.getColumnModel().getColumn(i).getCellRenderer().getClass())){
this.table.getColumnModel().getColumn(i).setCellRenderer(new ColorCellRenderer(new Color(255,255,190),0));
this.table.getColumnModel().getColumn(i).setCellRenderer(new ColorCellRenderer(new Color(255,255,190),1));
}
}
Ele pinta apenas a linha 2… :evil:
[/up]
[up2]
Agora funciona corretamente!
No ColorCellRenderer: private int[] rows;
public Component getTable..(params){
if(this.color != null && this.rows != null){
for (int i = 0; i < this.rows.length; i++) {
int rowToPaint = this.rows[i];
if(rowToPaint == row){
this.setBackground(this.color);
}
}
}else if(this.color != null){
this.setBackground( this.color );
}
}
Usage:
int[] rows = {0,1};
for(int i = 0; i<this.table.getColumnCount(); i++){
if(!CheckBoxRenderer.class.isAssignableFrom(this.table.getColumnModel().getColumn(i).getCellRenderer().getClass())){
this.table.getColumnModel().getColumn(i).setCellRenderer(new ColorCellRenderer(new Color(255,255,190),rows));
}
}
[/up2]
Funcionando!