[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Images doesnt take the background in a table.

Hello,

In our application, icons in my table is not taking the background i am setting to its row. When i checked with a SWT only snippet, i observed the same behaviour! Snippet is as below...

package test.TABLE;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;

public class TestTable3 {

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
final Table table = new Table (shell, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
table.setHeaderVisible (true);
table.setLinesVisible (true);
final int rowCount = 10, columnCount = 2;
for (int i=0; i < columnCount; i++) {
TableColumn column = new TableColumn (table, SWT.NULL);
column.setWidth(1000);
column.setText ("Column " + i);
}
for (int i=0; i < rowCount; i++) {
TableItem item = new TableItem (table, SWT.NULL);
for (int j=0; j < columnCount; j++) {
item.setImage(createImage(display,255,0,255));
item.setText (j, "Item " + i + "-" + j);
}
}
for (int i=0; i < columnCount; i++) {
table.getColumn (i).pack ();
}
Point size = table.computeSize (SWT.DEFAULT, 200);
table.setSize (size);
shell.pack ();
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}


	private static Image createImage(Display display, int red, int green,
			int blue) {
		Color color = new Color(display, red, green, blue);
		Image image = new Image(display, 10, 10);
		GC gc = new GC(image);
		gc.setBackground(color);
		gc.fillRectangle(0, 0, 10, 10);
		gc.dispose();

		return image;
	}
}

Is it a SWT limitation? If yes, is there any way to work around it?

Regards,
Supreetha