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

[404 byte] By [Irfan_dcrtia] at [2007-11-27 9:33:25]
# 1

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

BugBunnya at 2007-7-12 22:54:58 > top of Java-index,Java Essentials,Java Programming...
# 2
Hi Yeah, I achieved this for a row. Thanks!Irfaan
Irfan_dcrtia at 2007-7-12 22:54:58 > top of Java-index,Java Essentials,Java Programming...