Change ui component background at runtime?

Hi,

are there anyway to change the background of an component at runtime without css. Because I want to style the UI at runtime with an color chooser.

Aren’t there supported methods for an component like component.setBackgroundColor(blue); ?

Thanks for help.

cheers,

p.walzer

You can use a good add-on at
CssInject

Hi Ebrahim Pasbani,

thanks for the tipp, but when I want to use this api, I need an com.vaadin.ui.UI. Where can I get this. I want to change the color of the vaadin button via an SWT Button. I reuse the VisualDesigner to show the vaadin components. So when I choose a color via SWT ColorDialog, what should be set for the CSSInject?

As Root Element of the Vaadin Application I only can use the com.vaadin.visualdesigner.server.EditorWindow.

How can I work around this?

Thanks for help.

best regards,

p.walzer

P.S. I forgot to tell you, the VisualDesigner uses vaadin version 6.8.5, is that the issue?

Hi,

when I tried to use this

		CSSInject css = new CSSInject();
		css.setValue(".custom-style { color: rgb(100, 200, 300); }");
		mainWindow.getContent().addComponent(css);

I get this Error
“The type com.vaadin.ui.UI cannot be resolved. It is indirectly referenced from required .class files”

Is this telling because of the wrong vaadin version?

cheers,

p.walzer

You can click the “Available for Vaadin 6” link on
the directory page of CssInject
to download the Vaadin 6 compatible version of it.

Hi,

If you’re using Vaadin 6 you shouldn’t use the Vaadin 7 version. Go to the directory page and click on Available for Vaadin 6 and use this version of the add-on instead.

The com.vaadin.ui.UI class is the main class in Vaadin 7 like the Application class is in Vaadin 6.