Most of the time I use FitLayout as my panel layout data in GXT. However when it comes to a panel contains many other panels, Fitlayout might not be the best solution. So the RowLayout come into scene.
It will like it:
centerPanel.add(actionPanel, new RowData(1, -1, new Margins(4)));
centerPanel.add(userActionPanel, new RowData(1, 1, new Margins(4)));
Problem: here all the panels use RowLayout. if content in “userActionPanel” has some collapsible panel, after resize the scroll bar will not be there when content is out of the browser.
I was confused by the constructor. The margin part which is pretty much like the way used in other layout data, is easy to understand. However the 1 and -1 looks odd.
According to the Doc:
- Values less than or equal to 1 are treated as percentages, with 1 = 100%.
- Values greater than 1 are treated as pixels.
- Values equal to Style.DEFAULT (-1) will use the component’s computed height.
If we use Vertical orientation, the layoutVertical() will be called and it iterates all the child component and call setSize for them. This way, if any of the component is using 1 as height in the constructor. it will get an actual height value which will prevent the scroll bar from appearing when content get out of the browser window. Hence, my preference is using -1 all the time.