Setting Background image on panel

2,384 views
Skip to first unread message

rla...@googlemail.com

unread,
Jul 28, 2009, 2:13:36 PM7/28/09
to Google Web Toolkit
Hi all,

i'm new to GWT. I would like to know if there is a way to set a
background image on a panel.

thanks

Rodrigue Lagoue Njinthe

unread,
Jul 28, 2009, 4:50:10 PM7/28/09
to Google-We...@googlegroups.com
Hi again,

i spent all the day looking for a solution, the only things i found, were
for people working with GWT-Ext JS. Does somebody know if it's possible to
set an image as panel's background?

thanks for any help

Ed

unread,
Jul 29, 2009, 3:38:56 AM7/29/09
to Google Web Toolkit
Do you know how to set the background-image of any html tag, like a
DIV through CSS?

1) If yes: then you have your solution as you only have to set the CSS
name on your widget/panel through for example setStyleName(String).
2) If not: please have a look at some HTML book how to do this and go
back to 1)...

Extra info: go through a a tutorial of GWT, as it's basically the
first thing they explain..

Rodrigue Lagoue

unread,
Jul 29, 2009, 4:22:58 AM7/29/09
to Google-We...@googlegroups.com
Hi Ed

at first thanks for your answer. 

"1) If yes: then you have your solution as you only have to set the CSS
name on your widget/panel through for example setStyleName(String)."

it's the first thing i tried. But it didn't work at all. here is a listing of the involved part in my css file:

.rightPanelReservedZone {
background-image: url(images/bgleer.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
height: 90%;
width: 85%;
}

and i then add a new style by calling:


//rightPanel.addStyleName("rightPanelReservedZone");
rightPanel.setStyleName("rightPanelReservedZone");

Like you can see, i tried the both methods, but without success.

I thought it could be a problem with the image's path. But to my surprise, i the image was found as i try the following panel.add(new Image("images/pic.jpg"))

Nuno

unread,
Jul 29, 2009, 10:25:40 AM7/29/09
to Google-We...@googlegroups.com
but you may be setting the wrong path... unless your css file is located on the same page as the html... 

otherwise you would be looking at:

blablabal/css/images/bgleer.jpg from your css

and 

blablabal/images/bgleer.jpg from your GWT/html code
--
Quer aprender a programar? acompanhe:
Wants to learn GWT? Follow this blog ->

http://tcninja.blogspot.com


Rodrigue Lagoue

unread,
Jul 29, 2009, 10:47:41 AM7/29/09
to Google-We...@googlegroups.com
hi Nuno!

no the path .../pic.jpg was just an example. 

i found out that the problem could be that the panel who supposed to have the image background is empty. If i put some widgets on this panel, the image background become visible. I cannot explain why.

thanks

Ed

unread,
Jul 30, 2009, 5:56:39 AM7/30/09
to Google Web Toolkit
Your css contains a mistake: you have to set a fixed height and width
on your panel, and not through %.
Try it and you will see it works.
You did the same by adding a widget to it.



Manuel Carrasco Moñino

unread,
Jul 30, 2009, 12:53:04 PM7/30/09
to Google-Web-Toolkit
You change your css by:

.rightPanelReservedZone {
background: red;
}

If you can see the panel's backgroud in red, the problem is in the image's url.

Also you can check if there is any error using firebug

Manolo Carrasco

2009/7/29 Rodrigue Lagoue <rla...@googlemail.com>
Reply all
Reply to author
Forward
0 new messages