Forkmohit
Forkmohit

Reputation: 753

GWT: Adding style to child of Horizontal Panel

I have a HorizontalPanel, that translates to a table (HTML). I want to add styling to second column (td) of the generated table. Or, the surrounding Anchor tag ?

How to do it?

       <g:HorizontalPanel ui:field="horizontalPanel">
            <b:Image url="images/default.png"/>

            <b:Anchor> </b:Anchor>
        </g:HorizontalPanel>

Upvotes: 3

Views: 777

Answers (1)

Knarf
Knarf

Reputation: 2156

horizontalPanel.getWidget(1).setStyleName("abc");

or in uibinder

<b:Anchor addStyleNames="{style.blaBla}"</b:Anchor>

or for the parent item

horizontalPanel.getWidget(1).getElement().getParentElement().getStyle().set....

or

horizontalPanel.getWidget(1).getElement().getParentElement().setAttribute("class", "abcd");

Upvotes: 3

Related Questions