Pradeep, 

It seems like there are a few things you can do.  Here are a couple of
suggestions.  

First, look at the source for
DefaultTableCellRenderer.getTableCellRendererComponent() to get a sense of
how the default behavior works.  It sounds like when you subclass the
renderer you are just setting the text of the label and not setting the
foreground/background depending on the selection state.  Simplest thing,
therefore, is, in your subclass, set the background/foreground for your date
column.

By default, the displayed value is obtained by calling toString() on the
value object passed in.  You can vary this behavior by specifying a
different class to be returned from your table's model, in getColumnClass().
For instance, if you return Date.class for your date column, the table will
use a DateRenderer for that column; DateRenderer uses a DateFormat to format
the date.  Look in JTable.java  to learn more about this.

Hope this helps, rand

--------------------------------
Rand Clark
Software Design Engineer
Transoft Networks
a Hewlett-Packard company
805.883.4315
[EMAIL PROTECTED]
--------------------------------


-----Original Message-----
From: Pradeep, Chinnaswamiah [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 4:13 AM
To: [EMAIL PROTECTED]
Cc: Praveen Kumar, Irrinki; Balabaskaran, Kanagasabai
Subject: Problem with Table cell renderer


Hi ,

         I  have  extended the DefaultTableCellRenderer  to  have my own
TableCellRenderer. I am using this  Renderer for  all columns in a JTable .
One
of my column  has a datefield  which is to be formatted . So for this
particular
column  I return a  JLabel from the getTableCellRendererComponent() function
of
the renderer else i just return a component ( which I get from
super.getTableCellRendererComponent() with a change in the foreground color
of
the component ).

        Now  when  I select a row all the columns of that row get
highlighted
except for the column having the datefield.If  I return a component instead
of
a JLabel from my renederer for this column then everything works fine but
the
format of the datefield is lost  because I cannot set the text of a
component.

        Any suggestions in this regard.

Thanks
Pradeep
_______________________________________________
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