| [news.eclipse.platform.swt] Re: JFace Table: getColumnImage always returns all black |
Bill Ewing wrote:
There sure are a lot of us with table viewer questions.
We want to use getColumnImage to return an image which is generated on the fly. This, we believe, will allow us to draw anything in any cell and help us overcome various inadequacies in the tables.
For example, try to make the text in a cell left-justified when the heading is centered. Or, achieve an Excel-like appearance with row header "buttons" in the leftmost column.
So, it should be pretty easy, right? In the getColumnImage method of the table's label provider, we should be able to create a new image, get a GC for it, draw on it and then return it.
Our code looks like what's shown below. Anybody have a clue why it never works? It always makes an all black rectangle. TIA, Bill.
=============================
public Image getColumnImage(Object element, int columnIndex) {
switch (columnIndex) {
case 1:
Display d = Display.getCurrent();
image = new Image(d, 35, 14);
GC gc = new GC(image);
image.setBackground(new Color(d, 0, 123,88)); gc.setBackground(d.getSystemColor(SWT.COLOR_RED)); gc.fillRectangle(0,0,34,14); return image; default: return null; } }