aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes SWT tableitem, image not displaying properly. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT tableitem, image not displaying properly." Watch "SWT tableitem, image not displaying properly." New topic
Author

SWT tableitem, image not displaying properly.

Bill Coider
Greenhorn

Joined: May 14, 2010
Posts: 4
I have a tableItem in an swtTable where I use an image in the first cell *with indent*.

A few problems -
first, I discovered the table background color bug, where the background behind my image is reverting to the *table* bgColor, and not the table *item* bgColor (result is that even though my row is blue, the image column has a black background (black is the table background color, also the area that is 'indented' is the same black color.

Second, i figured that the easiest way would be to custom draw the indented image (instead of using tableitem.setImageIndent()) with the indent already in the image, and just setting the image into the tableitem and drawing the background correctly, on the fly.
this does not work either, because now, even though the background color behind the image is correct, the column has a black border between all the cells. this only affects the column with the image, and it looks very ugly.

Third, i tried just manually drawing the image using the table's GC (gc = new GC(table)), which actually looks good (i guess the black borders above were coming from code in the standard item drawing, whereas here i am actually drawing 'over' the table, hence it is not subject to any of those issues.)
HOWEVER, now, when i select a row, the image i draw gets clobbered when the row selection highlight is drawn in. i have some listeners in place to take care of redrawing , but here's the catch - we have DND (drag and drop) enabled on this table, which hangs the redrawing until the drag is done. so when you click on a row, you get these ugly flickers while the mouse is down (and windows is waiting to see if a drag is going to start, during which it eats event and drawing is halted).

any of those solutions would work fine if not for a small issue. can anyone help?

P.S. i forgot - I also tried one other strategy, which was drawing in the background manually, using an EraseItem listener. this looks fine, but is very slow (we have upwards of 50 columns, potentially more) when scrolling horizontally.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SWT tableitem, image not displaying properly.
 
Similar Threads
2d graphics context from component to image
Graphics Object & Graphics Context
Making translucent images
Is this possible to do?
Color in JTable