You will probably need to write a cell renderer to color the row.

You can extend DefaultCellRenderer, override the method 
getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) and set the background color,
in that method.

class ColoredTableCellRenderer
    extends DefaultTableCellRenderer
{
    public Component getTableCellRendererComponent
        (JTable table, Object value, boolean selected, boolean
focused, int row, int column)
    {
        setEnabled(table == null || table.isEnabled());

        if ((row % 5) == 0)
            setBackground(Color.green);
        else
            setBackground(null);

        super.getTableCellRendererComponent(table, value, selected, focused, row, 
column);

        return this;
    }
}

then use table.setDefaultRenderer



On Fri, 29 Mar 2002, SHASHANK KOLHE wrote:

> Date: Fri, 29 Mar 2002 23:25:11 -0800 (PST)
> From: SHASHANK KOLHE <[EMAIL PROTECTED]>
> To: "Reinstein, Lenny" <[EMAIL PROTECTED]>,
>      'Dave Wathen' <[EMAIL PROTECTED]>, 'baski' <[EMAIL PROTECTED]>,
>      Norell Peter <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Subject: Changing color of particular row in Jtable.
>
>
> hi friends,
> i want to do as fallows....
> i have the Jtable where i am receiving all the
> messages.
> when mwssage has come it has some color indicating it
> as a new message.
> 1.now i want to change the color of the selected
> row(after reading the message) in the
> Jtable(foreground or background anything is fine).
> 2.or can i change the font as bold /normal depending
> upon the new/old message.
> (like in yahoo mail)
>
> can anybody help me on this lines urgently.
>
> regards,
>
> ...Shashank
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Greetings - send holiday greetings for Easter, Passover
> http://greetings.yahoo.com/
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
>

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to