使 gwt 按钮透明

  • 本文关键字:透明 按钮 gwt java gwt
  • 更新时间 :
  • 英文 :


我在基于 GWT 的应用程序中有一些按钮。每个按钮都包含一个图像。这个想法是只显示按钮中包含的图像,而不是按钮本身,而是继承按钮的功能和属性,因为我在 hashMap 中使用按钮:

final Map<Button, Integer> buttonRowMap = new HashMap<Button, Integer>();

我可以向您展示与"问题"相关的代码:

final Button gu = new Button();
buttonRowMap.put(gu, i);
Image imggu = new Image("Imagenes\Add.png");
imggu.setSize("25%", "25%");
gu.getElement().appendChild(imggu.getElement());
gu.getElement().setId(""+i);
gu.setTitle("Modify");

我想要实现的结果是在我的 gwt 中显示图像,就好像它是一个按钮一样,但不显示它嵌入的图像的按钮。

谁能帮我?

谢谢。

我建议使用 css 执行此操作。

button.setSyleName("add")

然后在 css 中

button.add {
  background: url(images/add.png) no-repeat center center fixed;
  border: none;
}

您需要将 add.png 放在/images/add 的公共目录中.png

另一种选择是您可以使用 CssResource 和精灵将背景图像添加到按钮。

最新更新