Saturday, October 26, 2013

Re: Center a VerticalPanel

I'd like to add that what is actually in vp is more complex than just some text.  There are input controls too.  So, the solution can't rely on just centering text.  It must deal with a VerticalPanel as a widget.


On Sun, Oct 27, 2013 at 12:34 AM, Blake McBride <> wrote:

I have a VerticalPanel that I would like to appear in the center of a browser window and remain in the center on browser resizes.

I tried:

RootLayoutPanel rlp = RootLayoutPanel.get();
VerticalPanel vp = new VerticalPanel();
vp.add(new Label("Line 1"));
vp.add(new Label("Line 2"));
vp.add(new Label("Line 3"));
rlp.setWidgetLeftRight(vp, 40, Unit.PCT, 40, Unit.PCT);
rlp.setWidgetTopBottom(vp, 40, Unit.PCT, 40, Unit.PCT);

This gets close but (obviously) doesn't calculate the middle correctly.  Also it is important that the center of vp is placed in the middle of the screen and not the upper left corner of vp.  

I am looking for an all-Java solution if possible.  I have already spent about 8 hours on this.

I really appreciate the help!

Blake McBride

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment