在你的战争中(如果你使用 ecilpse,这将在 WebContent 中)在这个路径中有一个文件 VAADIN/themes/customrunno/styles.css (假设你使用 runno 作为你的主题)
有了这个内容:
@import url(../runo/styles.css);
.my_bg_style {
background: #99EE6B;
}
Run Code Online (Sandbox Code Playgroud)
在您的 init 方法中:
setTheme("customruno"); // same as the folder folder under VAADIN/themes
Run Code Online (Sandbox Code Playgroud)
更改您的文本字段背景:
textField.addStyleName("my_bg_style"); // same as in styles.css
Run Code Online (Sandbox Code Playgroud)
删除样式只需执行以下操作:
textField.removeStyleName("my_bg_style");
Run Code Online (Sandbox Code Playgroud)