4

I've come across some legacy code which uses SmartGWT. I suspect the API is present in standard GWT too.

widget.setWidth("*");

Keeping in mind that the same bit of code has:

otherWidget.setWidth100();

I'm not aware that CSS has anything like:

width: *;

So... is this code legitimate and if so what does it do... or not?!

Thanks in advance.

rich
  • 18,987
  • 11
  • 75
  • 101

2 Answers2

6

In SmartGWT .setWidth("*") means take up the rest of the available width. For example, if you have a HPanel with two children and one of the children has setWidth("10%") then implicitly the child with setWidth("*") will have 90% width. This allows you to change the width of one child without having to update the other setWidth call.

minichate
  • 1,914
  • 13
  • 17
  • 1
    It's perfectly llustrated by the showcase: http://www.smartclient.com/smartgwt/showcase/#layout_layout one can see the two fixed percentage column and the rest when resizing the window – Alain BUFERNE Jan 21 '13 at 14:36
2

Consider that you have a Panel with two children. Now if you set setWidth("*") for both child then the first child will take the required width and the second child will get whatever is left.

If you set setWidth("60%") for the first child and setWidth("*") for the second child then first child will take 60% of the width of the Panel and the second child will get the remaining 40%.

.setWidth100(); and .setHeight100(); these 2 make the component fill the canvas it is in. This mean set width & height 100% which is equivalent to setWidth("100%") and setHeight("100%") respectively.

This is basically used when you don't specifically want to set the widths of the child panel's. You specify a rough width of the first child panel and the width of the second child is automatically set.

Sunil Kumar
  • 1,389
  • 2
  • 15
  • 32