Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何设置文本按钮的样式?_Java_Gwt - Fatal编程技术网

Java 如何设置文本按钮的样式?

Java 如何设置文本按钮的样式?,java,gwt,Java,Gwt,我有一个GWTtext按钮。应用于全局css文件的以下css样式不起任何作用: .gwt-TextButton { color: red !important; } 为什么??更改所有TextButton小部件样式的正确样式是什么?TextButton是一个基于单元格的小部件,基于模式。它使用textbutoncell呈现内容,并使用CellWidget包装内容 您正在寻找的全局css是gwt buttoncelbase,但由于它在ClientBundle中使用,因此需要扩展button

我有一个GWT
text按钮
。应用于全局css文件的以下css样式不起任何作用:

.gwt-TextButton {
   color: red !important;
}

为什么??更改所有TextButton小部件样式的正确样式是什么?

TextButton
是一个基于单元格的小部件,基于模式。它使用
textbutoncell
呈现内容,并使用
CellWidget
包装内容

您正在寻找的全局css是
gwt buttoncelbase
,但由于它在
ClientBundle
中使用,因此需要扩展
buttoncelbase.DefaultAppearance.Resources
,提供您自己的
样式。与其他基于细胞的小部件非常相似。然后需要使用正确的构造函数(
TextButton(外观,字符串文本)
)。下面是示例代码

定义资源外观扩展(为了清晰起见,完全引用):

custom.css
中,覆盖您想要的任何内容,然后注入所有内容:

MyResources customResources = GWT.create(MyResources.class);
TextButtonCell.Appearance customAppearance = new TextButtonCell.DefaultAppearance(customResources);
TextButton button = new TextButton(customAppearance, "Text");

您只需一次就可以很好地完成上述所有操作,并始终实例化具有相同外观的任何新的
TextButton

我只能将外观构造函数与(SafeHtmlRenderer,Resource)一起使用。我在哪里可以买到这个?我不想自己供应。我只是想提供我自己的CSS样式。为什么要这么复杂呢?@membersound添加了示例代码。我知道不是那么简单。这应该在官方文件中,这是很容易理解的!
MyResources customResources = GWT.create(MyResources.class);
TextButtonCell.Appearance customAppearance = new TextButtonCell.DefaultAppearance(customResources);
TextButton button = new TextButton(customAppearance, "Text");