Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想更改文本框的背景颜色作为正在验证的指示符。
<ui:style> .textBoxColor { background-color: #FF6EB4; } </ui:style>
进而
if(firstName.equals("")) { txtFirstName.setStyleName("textBoxColor"); }
然而,这并没有给出预期的结果。
我怎样才能实现颜色的变化?
亲切的问候
如果我没记错的话,在 UIBinder 中声明的 css 名称会在编译时转换 - 因此将样式设置为textBoxColor不起作用,仅仅是因为不会有具有该名称的样式。
textBoxColor
如果您将其添加到外部 css 文件(可能具有更具描述性的名称,例如... .validated),setStyleName()将起作用。
.validated
setStyleName()