You cannot display the RootPanel
in the center of the screen since the RootPanel
is the <body>
of the document itself, it has no position.
What you want is to add a base panel to the RootPanel
which will be centered horizontally. That new panel (suppose a FlowPanel
) will hold all other widgets, and that panel can have a position, which means it can be centered.
Something along these lines should do:
RootPanel rp = RootPanel.get();
FlowPanel fp = new FlowPanel();
fp.add(allYourWidgets);
fp.addStyleName('center'); // where center is a css rule with "margin: auto;"
rp.add(fp);