Joey
Joey

Reputation: 2792

GWT how to add css style on Image Resource

I am using GWT. I have an Image Resource object. for example,

 ImageResource image = ClientResources.of().images().icon();

How can I add some css styles on this image. Since this is ImageResource, not the Image object, I cannot use image.addStyleName(). I am not using ui-binder. So how could I achieve this?

Because I am newb in GWT, if you answer could provide some codes, that would be more clear and really appreciated.

Best Regards.

Upvotes: 1

Views: 1242

Answers (1)

Chris Cashwell
Chris Cashwell

Reputation: 22859

How are you displaying the image? You can't perform CSS operations on an ImageResource directly, but neither can you display it directly. You have to stick it in an Image, ImageResourceCell, or some other object, all of which are able to be styled. So you'd want to style the renderer, not the ImageResource itself.

For example:

ImageResource imageResource = ClientResources.of().images().icon();
Image image = new Image(imageResource);
image.addStyleName("someCoolStyle");

Upvotes: 1

Related Questions