[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Drawing to GC

Hello,

I would like to dynamically generate the labels for a Tree.  The labels must
be circles with varying colors.  I don't have the labels as images in a
file, so I need to create the Image dynamically in the code.  This is what
I've tried:

Image label = new Image(null, 15, 15);
GC gc = new GC (label);
gc.setBackground(ColorConstants.blue);
gc.fillOval(0, 0, 15, 15);
return label;

However, the labels that get displayed by this are just black squares.  I
have also tried:

Image label = new Image(Display.getCurrent(), 15, 15);

with the same effect.

I have tried this with both a JFace TreeViewer by implementing the
LabelProvider and an SWT Tree widget by using TreeItem.setImage(img);  Both
methods produce a tree with black squares for labels.

Is this the correct way to draw to a GC?  Am I missing something?

Any help is greatly appreciated. Thanks!

Angel