You need to write custom renderer of this JTable.
Following code might help.
public class MultiColorCellRenderer extends JLabel implements TableCellRenderer
{
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
{
if( 0 == row)
{
setBackground(Color.red);
}
else if( 0 == row)
{
setBackground(Color.green);
}
else
{
setBackground(table.getBackground());
}
setText(value);
return this;
}
}
You need to set this renderer for ur table
table.setDefaultRenderer(new MultiColorCellRenderer());
For header you need to write one more renderer with its paint overriden.
> Hi,
> I need to build a JTable that has: - custom rows (i.e. alternate colour rows, first
>one yellow, second one white, third one
yellow etc) -column headers with a custom (blue) backColor -no borders. Does anyone
have the code for this?
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing