At the moment I select any cell the whole row is selected, what I want is that when you select any cell you focus on that cell of one color and so on with the others, be careful that you follow the selection of the whole row.
At the moment I select any cell the whole row is selected, what I want is that when you select any cell you focus on that cell of one color and so on with the others, be careful that you follow the selection of the whole row.
For that you must make a custom render and put it to all the columns that you want to have that behavior. The code for the render would be:
TableCellRenderer render = new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component c = table.getDefaultRenderer(table.getColumnClass(column))
.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(hasFocus)
((JComponent)c).setBackground(Color.GREEN);//Pones el color que quieras
return c;
}
});