Dmitry
Dmitry

Reputation: 423

GWT AbsolutePanel not shown in browser

I create widget containing AbsolutePanel using GWT UiBinder like this:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
   xmlns:g='urn:import:com.google.gwt.user.client.ui'>
   <g:VerticalPanel>
       <g:Label>Label1</g:Label>
       <g:AbsolutePanel height="500" width="500">
           <g:at left='10' top='60'>
               <g:Label>Label2</g:Label>
           </g:at>
           <g:at left='10' top='100'>
               <g:Label>Label3</g:Label>
           </g:at>    
       </g:AbsolutePanel>
       <g:Label>Label4</g:Label>
    </g:VerticalPanel>
</ui:UiBinder>

Than create corresponding class :

public class TestAbsPanelWidget extends Composite {
    @UiTemplate("TestAbsPanelWidget.ui.xml")
    interface MyUiBinder extends UiBinder<Widget, TestAbsPanelWidget>  {}

    private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

    public TestAbsPanelWidget() {
        initWidget(uiBinder.createAndBindUi(this));
    }
}

Than use it my GWT entry point like this:

public class TestAbsPanel2 implements EntryPoint {
    public void onModuleLoad() {
        RootPanel.get("div_id").add(new TestAbsPanelWidget());
    }
} 

After that I see "Label1" and "Label4" on screen in browser, but no "Label2" and "Label3". It seems that AbsolutePanel not shown. What am I doing wrong help me please.

Upvotes: 0

Views: 75

Answers (1)

Adam
Adam

Reputation: 5589

You try to set the panel's width and height with:

<g:AbsolutePanel height="500" width="500">

but you don't specify CSS units. Try:

<g:AbsolutePanel height="500px" width="500px">

and you will see Label2 and Label3.

Upvotes: 2

Related Questions