Hi Sidni,

I think the problem is because the width of the HorizontalPanel is too
small.

Try this,

        Label l = new Label("Hello");
        HorizontalPanel hp = new HorizontalPanel();
        hp.setBorderWidth(1);
        hp.setWidth("100%");
        hp.add(l);
        hp.setCellHorizontalAlignment(l, HorizontalPanel.ALIGN_CENTER);
        RootPanel.get().add(hp);


Tip: it is always useful to set border of the panel when troubleshooting
alignment problem :-)


On Thu, Sep 3, 2009 at 11:51 PM, sidni <[email protected]> wrote:

>
> Hi,
>
> Consider 2 code snipet below:
> My intention is to display "Hello" in Center of the page.
>
> 1. Using Label directly
>
> Label l = new Label("NITESH");
> l.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
> RootPanel.get().add(l);
>
> This displays it in center.
>
> 2. Label widget contained in Vertical/HorizontalPanel
>
> -------------------------------------
> HorizontalPanel hp = new HorizontalPanel();
> Label l = new Label("Hello");
> hp.add(l);
> hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
> //hp.setCellHorizontalAlignment(l,
> HasHorizontalAlignment.ALIGN_CENTER);
> RootPanel.get().add(hp);
> -------------------------------------
>
> If we replace HorizontalPanel with VerticalPanel we get result the
> same.
>
> How would I display my label at Center of page if its contained under
> some Panel ? Am I missing something ?
>
> 10x
>
> >
>


-- 

Hez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to