簡體   English   中英

Vaadin:動態更改文本字段的背景顏色

[英]Vaadin: Dynamically change a textfield's background color

如何動態更改文本字段的視覺屬性,比如背景顏色?

一個示例可能是在驗證期間根據輸入的值修改背景顏色。

這是樣本

.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

在你的戰爭中(如果你正在使用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");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM