염경훈
염경훈

Reputation: 27

How to add Text and Image both in an SWT Label

I heard that Label is impossible, but CLabel is possible. How to use CLabel to add text & image?

private CLabel label = new CLabel(composite, SWT.CENTER);
label.setBounds(93,35,192, 20); 
label.setImage(SWTResourceManager.getImage("C:\\Users\\Screen.png"));
label.setText(memName + "'s Planet");

this is my code. but only display text or image....

Upvotes: 0

Views: 511

Answers (2)

stevops
stevops

Reputation: 439

You could use set setBackgroundImage()

Upvotes: 1

greg-449
greg-449

Reputation: 111142

CLabel does display the image and the text.

However if there is not enough space for both the image and the text it will leave out the image - so check you have enough space for both.

To display a background image call the CLabel setBackground(image) method.

Upvotes: 0

Related Questions