Forkmohit
Forkmohit

Reputation: 753

GWT Unable to add background image to Simple Panel

I have a SimplePanel and I am trying to set it's background image programatically but below method doesn't work. Why?

this.coverImage.getElement().getStyle().setBackgroundImage("images/veg.jpg");

For :

Style:

.coverImage{
  width:400px;
  background-color:#e5e5e5;
  background-repeat: no-repeat;
  height:190px;
  z-index:-1;
}

However, adding background-image: url("images/veg.jpg") works.

Upvotes: 2

Views: 961

Answers (1)

Adam
Adam

Reputation: 5599

You almost got it ;)

this.coverImage.getElement().getStyle().setBackgroundImage("url('images/veg.jpg')");

Upvotes: 4

Related Questions