PDA

View Full Version : Problem with BorderLayout.SOUTH and Image



slayor
1 Sep 2011, 1:54 AM
Hello everyone,
First of all sorry if this is not the right place to put this question.

I created an application taking the example of BorderLayout. The difference is that I added a background image on top of the web page.

The problem is that my south panel is not entirely visible and the StatusBar I added to this panel is not visible at all ("Before" screenshot).

I can solve this problem by resizing the browser size ("After" screenshot).

Is there any way to fix this problem ? Maybe there is a way to "simulate" the resizing of the browser but I couldn't find it...

Thanks in advance.

sven
1 Sep 2011, 2:03 AM
Would it be possible to post your code in a small, standalone testcase that implements EntryPoint? This way it would be much easier to help you

slayor
1 Sep 2011, 2:17 AM
Sorry, I forgot to post my code.

slayor
1 Sep 2011, 2:28 AM
Another information : if I remove the top image, it works perfectly but I want to have this image in my application.

vtysh
1 Sep 2011, 3:57 AM
Did you try to specify the border layout panel height explicitly?

slayor
1 Sep 2011, 6:43 AM
I tried to do "setHeight(Window.getClientHeight());" after "add(south, southData);" in BorderLayoutExample class but nothing happened...

vtysh
1 Sep 2011, 11:40 PM
Did you try to set heigh which is less than window client height on the height of that background image you used?

slayor
1 Sep 2011, 11:47 PM
Yes, I tried. I even tried to do "setHeight(100);" and still nothing happened...

slayor
6 Sep 2011, 6:22 AM
Does anyone have a clue for this problem please ?

Colin Alworth
6 Sep 2011, 2:34 PM
From your code,

image = new Image("ProgServer.png");
viewport.add(image, new RowData(1, -1));

I'm assuming from your discussion with sven that you've tried to set the second parameter to be the height of the image?

This is likely happening because the image doesnt load right away, so the layout can't tell how much room it should leave.

Another solution would be to use -1 as the height (meaning measure during layout), and call viewport.layout(true) again after the image has loaded (this is the same code that resizing the browser calls). This can be done through the Image method addLoadHandler.

Also, please consider making small examples in one class - while this will take more time on your part, it is much easier for us to read, and in changing the setup, you might learn more about what other things affect the issue you are having.

slayor
7 Sep 2011, 1:15 AM
Great, I added the following lines at the end on the onModuleLoad method :

image.addLoadHandler(new LoadHandler() {

@Override
public void onLoad(LoadEvent event) {
viewport.layout(true);
}
});

It's finally working, thank you very much !


Also, please consider making small examples in one class - while this will take more time on your part, it is much easier for us to read, and in changing the setup, you might learn more about what other things affect the issue you are having.

Ok, I'll take this advice next time.
Thank you again.