Search code examples
gwtalignment

Setting alignment in verticalpanel - gwt


I am trying to set the align property in vertical panel in GWT like this:

vpanel = new VerticalPanel();
vPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

and then adding children which gives me a table like this:

<table>
<tbody>
<tr><td align="left"></td></tr>
<tr><td align="left"></td></tr>
</tbody>
</table>

But what I want is

<table align="left">
<tbody>
<tr><td></td></tr>
</tbody>
</table>

I know it's a stupid question but I am stuck with browser compatibility issue and only the HTML specified fixes issue on all browsers. Any ideas?


Solution

  • You can get the underlying element of a widget and set an attribute to it using getElement().setAttribute(..) for instance :

    VerticalPanel panel = new VerticalPanel();
    panel.getElement().setAttribute("align", "left");
    RootPanel.get().add(panel);