相反,您可以尝试执行以下操作以获得相同的结果.
>创建标签
>使用shell将图像分配给标签
>然后使用“setText()”在标签上写一些东西.
文本将出现在图像上方.您将能够看到图像.
(仅显示相关代码)
带文本/图像的标签示例.
Image image = new Image(display, "c:\\picture.jpeg");
Shell shell = new Shell(SWT.NO_TRIM);
shell.setBounds(10,10,200,200);
shell.setBackgroundImage(image);
shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
Label label = new Label(shell, SWT.NONE);
label.setText("LAbel text here. ");
既然你想制作按钮.
您也可以使用相同的逻辑,使用“Button”api.
您可以创建带有图像的按钮,然后在其上方设置任何文本.
(仅显示相关代码)
按钮的示例
Button button = new Button(shell, SWT.PUSH);
button.setImage(image);
button.setText("Click Me");
我希望这是你想要做的.