2

如何动态更改文本字段的视觉属性,比如背景颜色?

一个示例可能是在验证期间根据输入的值修改背景颜色。

4

2 回答 2

5

在您的战争中(如果您使用的是 ecilpse,这将在 WebContent 中)在此路径 VAADIN/themes/customrunno/styles.css 中有一个文件(假设您使用 runno 作为主题)

有了这个内容:

@import url(../runo/styles.css);

.my_bg_style {
     background: #99EE6B;  
}

在您的 init 方法中:

setTheme("customruno"); // same as the folder folder under VAADIN/themes

更改您的文本字段背景:

textField.addStyleName("my_bg_style"); // same as in styles.css

要删除样式,只需执行以下操作:

textField.removeStyleName("my_bg_style");
于 2013-07-01T17:51:06.080 回答
4

这是示例

.v-textfield-dashing     
{    
    border:     thin dashed;    
    background: white; /* Has shading image by default */    
}

您将在此链接上获得详细信息。 https://vaadin.com/book/-/page/components.textfield.html

如果您想动态更改文本字段颜色,那么您将在以下链接 https://vaadin.com/wiki/-/wiki/Main/Dynamically%20injecting%20CSS上获得内容

于 2013-05-31T01:36:57.737 回答