Dynamic coloring

Any experience with dynamically changing color Widget (background-)? afaik I can only change the name of the CSS style, but as the color is calculated I have no chance here?

I found something like this DOM.setStyleAttribute(mywidget.getElement(), "background", "#FF0000");

, but it looks pretty frustrating.

any ideas?

0


a source to share


1 answer


This is a pretty standard way to do it. If you only need to change the background color, you can create a function to do this:

public void setBgColor(String color)
{
    setStyleAttribute(this.getElement(), "background", color)
}

      



or if you want it to work with all widgets:

public void setBgColor(UIObject object, String color)
{
    setStyleAttribute(object.getElement(), "background", color);
}

      

0


a source







All Articles