Table cell renderer problem - paint problem?



I have a table which uses a custom TableCellRender.

In the code below, TColumn stores some configuration information about
a given column. if it's renderComponentType member is not equal to
"LABEL", it will return a custom component i created.
That component is called "IconLabel" and it is simply a panel with two
labels, one for an IconImage and the other for displaying the text. In
this case, my table consists of only one column out of 7 that uses
IconLabel.

Further, when ever a cell is clicked, i disabled SelectionAllowed on
the table and instead, i "outline" the ENTIRE row with a white border
to show that that row has been selected. this is accomplished by
overriding JTable's prepareRenderer method.

MY PROBLEM IS, whenever i click on a cell of the table, the entire row
is highlisted with the white outline border as it should, HOWEVER, then
i now click on a next row, the Column based on my IconLabel does NOT
reset. what i mean by that is that the border of the row i had clicked
before is still highlighted with a white border. why is this?

thanks much for any help:

here's a snippet of the code:
this determines what component to use in the renderer:
if ( tc.renderComponentType != TColumn.LABEL)
c = getComponentByTColType( stbl, tc, value.toString() );
else
c = ( JComponent ) super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, col );

this initializes IconLabel only the first time so it can be
reused(_iconLabel is a private member of the CellRenderer):
if ( tc.renderComponentType == TColumn.ICONLABEL )
{
if ( _iconLabel == null )
{
_iconLabel = new IconLabel( value.toLowerCase(),
tc.alignment);
_iconLabel.setFont( table.getFont() );
}
return _iconLabel;
}


and this is the code in my "Table" that overrides prepareRendere, below
getRowSelectionBorder simply creates a compound border to create an
outline around a row.:
public Component prepareRenderer( TableCellRenderer renderer,
int row, int column )
{
JComponent c = (JComponent) super.prepareRenderer(
renderer, row, column );


if ( !getRowSelectionAllowed( ) )
return c;

if ( isRowSelected( row ) )
c.setBorder( getRowSelectionBorder( c, column) );

return c;
}

.



Relevant Pages

  • Custom CellRenderer and paint problem.
    ... That component is called "IconLabel" and it is simply a panel with two ... is highlisted with the white outline border as it should, HOWEVER, then ... before is still highlighted with a white border. ... public Component prepareRenderer(TableCellRenderer renderer, ...
    (comp.lang.java.programmer)
  • Re: JTable - Row Sellection
    ... > special casing behavior of the renderers would be negated, ... and set a border on the renderer component, ... public Component prepareRenderer(TableCellRenderer renderer, ...
    (comp.lang.java.gui)
  • Re: Table Header
    ... > How can I change border of table header. ... Create a subclass of DefaultTableCellRenderer. ... Then you must set the table to use your custom renderer to render ...
    (comp.lang.java.help)