gpt4 book ai didi

java - 使 gwt 按钮透明

转载 作者:行者123 更新时间:2023-12-01 13:39:08 24 4
gpt4 key购买 nike

我在基于 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 的公共(public)目录中

另一个选项是您可以使用 CssResource 和 sprite 将背景图像添加到按钮。

关于java - 使 gwt 按钮透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20977159/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com