dav
21 May 2008, 1:36 PM
Hi,
I am trying to center a panel in a ViewPort. When panel had FitLayout everything was be fine, but when I set BorderLayout and add child North panel I got not centered parent panel (centerPanel).
Here is the code :
ViewPort viewport = new Viewport();
viewport.setLayout(new CenterLayout());
ContentPanel centerPanel = new ContentPanel(new BorderLayout());
centerPanel.setHeading("Centered");
centerPanel.setHeight(125);
centerPanel.setWidth(530);
centerPanel.setFrame(true);
ContentPanel northPanel = new ContentPanel(new FitLayout());
northPanel.setBorders(true);
northPanel.setHeaderVisible(false);
northPanel.add(new Html("<p>Header text</p>"));
BorderLayoutData data = new BorderLayoutData(LayoutRegion.NORTH, 30);
data.setMargins(new Margins());
northPanel.setData(data);
centerPanel.add(northPanel, data);
viewport.add(centerPanel);
RootPanel.get().add(viewport);
I try to debug with firebug and take result as shown on screenshot below.
When I manually remove (in firebug)
position: absolute; style attribute from centerPanel div tag panel rendered normaly in the center of viewport.
May be simplest solution is redefine 'position' attribute from java code after centerPanel creation (but all my attempts has no results - I cannot change this property). Any other fixes ?
I am trying to center a panel in a ViewPort. When panel had FitLayout everything was be fine, but when I set BorderLayout and add child North panel I got not centered parent panel (centerPanel).
Here is the code :
ViewPort viewport = new Viewport();
viewport.setLayout(new CenterLayout());
ContentPanel centerPanel = new ContentPanel(new BorderLayout());
centerPanel.setHeading("Centered");
centerPanel.setHeight(125);
centerPanel.setWidth(530);
centerPanel.setFrame(true);
ContentPanel northPanel = new ContentPanel(new FitLayout());
northPanel.setBorders(true);
northPanel.setHeaderVisible(false);
northPanel.add(new Html("<p>Header text</p>"));
BorderLayoutData data = new BorderLayoutData(LayoutRegion.NORTH, 30);
data.setMargins(new Margins());
northPanel.setData(data);
centerPanel.add(northPanel, data);
viewport.add(centerPanel);
RootPanel.get().add(viewport);
I try to debug with firebug and take result as shown on screenshot below.
When I manually remove (in firebug)
position: absolute; style attribute from centerPanel div tag panel rendered normaly in the center of viewport.
May be simplest solution is redefine 'position' attribute from java code after centerPanel creation (but all my attempts has no results - I cannot change this property). Any other fixes ?