Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » set background color in odd even row in table
set background color in odd even row in table [message #449134] Tue, 18 January 2005 17:18 Go to next message
Stavros Kounis is currently offline Stavros KounisFriend
Messages: 51
Registered: July 2009
Member
hi people

i need to set a different backgrount color in odd and even rows in my table

i have found this code snip :

private void fillTableColor(Table table){
TableItem item;
if (table != null)
{
for (int index = 0; index < table.getItemCount(); index+=2)
{
item = (TableItem)tableViewer.getTable().getItems()[index];
item.setBackground(new Color(null, 245, 245, 245));
}
}
}

but i dont like the idea that i have to "paint" my table again and again
after poppulate it with data

is it any other approach available


thanx

-stavros
Re: set background color in odd even row in table [message #449154 is a reply to message #449134] Tue, 18 January 2005 22:00 Go to previous message
Bill Ewing is currently offline Bill EwingFriend
Messages: 49
Registered: July 2009
Member
Stavros Kounis wrote:

"i need to set a different backgrount color in odd and even rows in my
table"

We have similar problems. One possible answer that we ran across that
might work for you is explained at:

http://wiki.schubart.net/wiki/wiki.phtml?title=How_to_Color_ Rows_in_a_TableViewer&printable=yes

In this article, an undocumented feature is exploited to set the back
color of rows. It involves implementing both ITableLabelProvider AND
IColorProvider in the label provider class used by your JFace table
viewer.
Previous Topic:Question about error "SWT Error: No more handles"
Next Topic:How to change selection color
Goto Forum:
  


Current Time: Tue Apr 23 16:16:18 GMT 2024

Powered by FUDForum. Page generated in 0.03132 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top