简体   繁体   中英

Vaadin set component color to hex or int or rgb

I am currently messing about with Vaadin.

I see that that I can change background color of eg button like so:

cButton.getStyle().set("background","red");

But if I want to set a specific color like this one: #EAB251. How can it be done?

This color could change depending on what the user chooses in an RGB-/HEX-/INT-color picker.

You can use any valid CSS value for the property. So cButton.getStyle().set("background", "#EAB251") and cButton.getStyle().set("background", "rgb(234, 178, 81)") should work. In fact, the line of code you posted works because red is a CSS color name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM