Saturday, October 26, 2013

Re: Center a VerticalPanel

Don't need to calculate. Jut put ur VerticalPanel into a Grid & centralise it.

Grid grid = new Grid(1,1);
grid.setWidget(0, 0, myVerticalPanel);
HTMLTable.CellFormatter formatter = grid.getCellFormatter(); formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); formatter.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
rlp.add(grid);

On Sunday, October 27, 2013 4:55:42 PM UTC+11, Blake wrote:
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.

Thanks!


On Sun, Oct 27, 2013 at 12:34 AM, Blake McBride <blak...@gmail.com> wrote:
Greetings,

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.add(vp);
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment