GWT 按钮中的图像 [已关闭]

2022-09-02 02:30:38

如何将图像添加到GWT按钮或如何使用Mosaic的按钮添加图像。我不知道如何在我的代码中使用此示例。我需要添加哪个库。我的项目中有Mosaic库,我可以使用它,但他们在那里的例子对我不起作用。

谢谢


答案 1

如果您只想将图像添加到普通的GWT按钮,那么PushButton就是要走的路:

PushButton pushButton = new PushButton(new Image("test.png"));

答案 2

PushButton没有相同的行为,你有一个比自己创建一个图像标签更漂亮的解决方案:

Image img = new Image("whatever.jpg");
Button button = new Button();
button.getElement().appendChild(img.getElement());

推荐