[英]How to add Text and Image both in an SWT Label
I heard that Label
is impossible, but CLabel
is possible. 我听说
Label
是不可能的,但是CLabel
是可能的。 How to use CLabel
to add text & image? 如何使用
CLabel
添加文本和图像?
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....
但仅显示文字或图像。
您可以使用set setBackgroundImage()
CLabel
does display the image and the text. CLabel
会显示图像和文本。
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. 要显示背景图像,请调用
CLabel
setBackground(image)
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.