AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Table cell renderer problem - paint problem?

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
farseer
Guest





PostPosted: Sun Apr 24, 2005 12:23 am    Post subject: Table cell renderer problem - paint problem? Reply with quote



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;
}

Back to top
farseer
Guest





PostPosted: Sun Apr 24, 2005 11:11 pm    Post subject: Re: Table cell renderer problem - paint problem? Reply with quote



yes, but what i don't understand is with out that "ELSE" clause, it
works fine for Cells that use JLabel as their rendering component.

Also, when i add the else clause to set the border to null, it works,
but still behaves a bit weird. for instance, if i click on row 5, then
click on row 4, row 4's border appears a thicker than the other
columns, as though it's drawing two borders. this only happens when
going from a lower row, to a higher row...just weird.

Back to top
farseer
Guest





PostPosted: Tue Apr 26, 2005 7:29 pm    Post subject: Re: Table cell renderer problem - paint problem? Reply with quote



Quote:
It only works fine for cells that use DefaultTableCellRenderer
because
at always resets the Border in getTableCellRendererComponent.

I see, that makes sense. thanks much


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.