Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sizing a HorizontalPanel cell

Tags:

gwt

Newbie Alert:

I have been furiously looking for a way to size a particular cell of a HorizontalPanel.

What I am trying to do is implement a 2-cell Horizontal Panel and set the left cell to say 200px. However, I am trying to make the right cell fill the rest of the window, not its cells contents.

I cannot see the wood for the trees, please help...

like image 600
user193867 Avatar asked Nov 03 '09 09:11

user193867


3 Answers

         HorizontalPanel horizontalPanel=new HorizontalPanel();
         horizontalPanel.setWidth("100%");
         Widget widget1=new Widget();
         Widget widget2=new Widget();
         horizontalPanel.add(widget1);
         horizontalPanel.add(widget2);
         horizontalPanel.setCellWidth(widget1,"200");

In above code if the widget2's width is set to 100% then widget2 will fill rest of the window.If the widget2's width is not 100% it will not fill rest of the window.Just check the width of your second cell content.It should not be 100%.

like image 76
DonX Avatar answered Nov 04 '22 11:11

DonX


I found I needed to tweak Damo's answer slightly to make this work. You have to set the explicit size of the widget in the first cell. But then set the second cell to have a width of 100%.

<g:HorizontalPanel width="100%">
    <g:cell>
        <g:SimplePanel width="200px"/>
    </g:cell>
    <g:cell width="100%">
        <g:SimplePanel width="100%"/>
    </g:cell>
</g:HorizontalPanel>
like image 40
jasop Avatar answered Nov 04 '22 10:11

jasop


Or if you are doing this with UiBinder:

<g:HorizontalPanel width="100%">
    <g:cell width="200">
        <!-- Stuff -->
    </g:cell>
    <g:cell>
        <!-- More Stuff -->
    </g:cell>
</g:HorizontalPanel>
like image 3
Damo Avatar answered Nov 04 '22 11:11

Damo