[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Adding Both Image and Text to Lables

Why not just have two labels? One with the text, one with the image. If
you use a FormLayout, you can pretty precisely control how they connect
with each other.

Alternatively, you can just draw the contents yourself. Here's a snippet
that adds a label to a Composite with a RowLayout. The RowData specifies
that the label should be a minimum of 100 pixels wide. You may have to
explicitly control the size with other layouts as well.

Label label = new Label(getButtonArea(), SWT.NONE);
label.setLayoutData(new RowData(100, SWT.DEFAULT));
label.addPaintListener(new PaintListener() {
	public void paintControl(PaintEvent e) {
		e.gc.drawRectangle(5, 5, e.width-10, e.height-10);
	}			
});

This example just displays a rectangle. There are other methods on GC
that draw text and images. It'll require a little math...

HTH,

Wayne


On Wed, 2008-04-30 at 12:26 +0000, S Prabhu wrote:
> Hello!
> 
> i have requirement to add a label in my own dialog,
> this label should have "text followed by image"...
> when i add image/text it overwrites other one.... please help me out to 
> keep both in label.....
> 
> Thanks
> S.Prabhu
>