0

I wan't to create a simple page using DockLayoutPanel, and I don't know why the main child in that panel doesn't get centered could anybody help?

public class Spr implements EntryPoint {
    public void onModuleLoad() {
        DockLayoutPanel panel = new DockLayoutPanel(Unit.EM);
        RootLayoutPanel.get().add(panel);
        panel.add(new HTML("center"));
    }
}

This just displays "center" in the top-left corner, while I expect it to display it in the middle of the page.

Thanks in advance.

2 Answers2

0

The center panel occupies all available space in the container. That's the reason you see the label displayed in the top left corner. Try setting other panels - south, west, north etc. Then you will get see desired behaviour.

Sree
  • 746
  • 6
  • 21
0

You have only added content to the center panel of the DockLayoutPanel.

Try adding left, right, north, etc.. to create other panels with DockLayoutPanel. You could add empty HTML:

panel.addNorth(new HTML(""), 2);

http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/ui/DockLayoutPanel.html

Peter Knego
  • 79,991
  • 11
  • 123
  • 154