Reputation: 1952
I was trying some examples with LayoutPanel in GWT. I tried to place a layoutpanel (with size 100%,100%) onto a ScrollPanel that in turn is attached to the rootlayoutPanel. Though the height I have assigned is 100%, it is not showing the layoutpanel to be filled in the rootlayoutpanel. Even if I add a widget to the layoutpanel, its not visible in the designer's view. I could view them by dragging explicitly the layoutpanel on the designer view. But, this would ultimately force the size to be in pixels. why am I finding this behaviour? below is the code:
RootLayoutPanel rp = RootLayoutPanel.get();
LayoutPanel lp = new LayoutPanel();
lp.setSize("100%","100%");
ScrollPanel sp = new ScrollPanel(lp);
rp.add(lp);
with this code, I could see the layoutPanel only as a line. I couldn't see the area (box) covered by Layoutpanel. If I try to manually change the height by dragging, it automatically changes the height of the layoutpanel to pixels:
lp.setsize("100%","500px");
why am I seeing this behaviour? Is there any explanation??
Upvotes: 0
Views: 5695
Reputation: 13519
Layout panels can be tricky. LayoutPanels are basically absolute panels, which are intended for full page web apps. To make it work all panels from the root panel down (or from the panel where resize is called and has a fixed size) must have RequiresResize
. In your case (besides the err in your example where you add lp instead of sp to the rootpanel, but I assume you intended sp to be added), you put a non LayoutPanel between the RootPanel and the LayoutPanel, this breaks the layout flow and thus the LayoutPanel lp can't be automatically resized. The LayoutPanel will get no height/width.
However, using a ScrollPanel together with LayoutPanels isn't going to work.The whole idea of a LayoutPanel is to derive it's size based on it's parent size, but inside a ScrollPanel the size isn't related, so the size of a LayoutPanel can't be set.
Upvotes: 7