Color the last row of a JTable
Hello,
I would like to set the background color the last row of a JTable automatically when a new row is added. I need all the rows of the JTable except the last row to have white background and the last row should have blue background. And, when I add a new row, the new last row should have blue background and the old one should get white background.
Thanks in advance,
Irfaan
Hi
im doing something like this
public class ColorTable extends JTable {
public Component prepareRenderer(TableCellRenderer r, int row, int col) {
Component c = super.prepareRenderer(r, row, col);
if (isCellSelected(row,col))
{c.setBackground(highlight);
c.setForeground(Color.BLACK);
}
}
}
of course you can adapt this to your own needs, e.g. instead of coloring the selected cell, you can color the last row or whatever you like
regards
BugBunny