Wednesday, July 1, 2015

Align text inside VerticalPanel in the middle

Hello everyone,
I am new to the GWT-EXT. I am trying to create area with red color background, then add a text and align the text to be in the middle. When I execute the code,
the text is always is left alignment. 
 
private VerticalPanel getHeader() {
    VerticalPanel verticalPanel =  new VerticalPanel();
    verticalPanel.setHorizontalAlign(Style.HorizontalAlignment.CENTER);
    verticalPanel.setStyleAttribute("backgroundColor", "red");
   
    Text  msg = new Text("Hello");
    // How can I align the message to be in the middle   
    verticalPanel.add(msg);
 
    return verticalPanel;
}
 
 
Then I call it as follow:
 
ViewPort viewport = new Viewport();
viewport.setLayout(new RowLayout(Orientation.VERTICAL);
viewport.add(getHeader());
 
 
Thanks for your help,
Tim

--
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/d/optout.

No comments:

Post a Comment