PDA

View Full Version : Column layout problem in a window



paulsschwarz
16 Sep 2008, 11:14 PM
There is some likelyhood I am misusing the layouts or something... I have been unable to find a good resource on 1. the lifecycle of a layout container, and 2. the proper use of layouts. So far my best resource is the explorer demo, is there something else out there that you can link me to?

I'm using 1.1 alpha 4 and here's what I think is a bug.



myWindow.setLayout(new FitLayout());

LayoutContainer panel = new LayoutContainer(new ColumnLayout());

LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout(LabelAlign.LEFT));

// ADD SOME FIELDS HERE USING: left.add(field);

LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout(LabelAlign.LEFT));

// ADD SOME FIELDS HERE USING: right.add(field);

panel.add(left, new ColumnData(.5));
panel.add(right, new ColumnData(.5));

myWindow.add(panel);

panel.setHeight(500);



Notice my very last line is set the height of the panel to 500. The problem is that the height of the panel is being calculated as the height of the left column PLUS the height of the right column, but then the columns do get rendered left and right correctly. So lets say my left column is 300px high and right column is 500px high what i get is:


|--- ---|
|--- ---|
|--- ---|
|... ---|
|... ---|
|... ...|
|... ...|
|... ...|


Dashes mean real content, dots mean empty space; notice the 300px of redundant height at the bottom of that rudimentary diagram?

Now there are two different problems it causes depending on the layout of the containing Window which is called myWindow in my code above.


1. myWindow.setLayout(new FitLayout()); causes the window to render way too tall in an attempt to accommodate the 300px of wasted space.
2. myWindow.setLayout(new FlowLayout()); causes the window to render the right (automatic) height but the window's shadow renders way too tall in an attempt to accommodate the 300px of wasted space.


So my only work around right now is to use FitLayout() so the shadow size is of course correct, but then explicitly set the panel's height to "crop" off the extra wasted space at the bottom. The height will be different for every type of window form I have! (:|

Something else I noticed is if I apply Scroll.AUTOY to the panel it kills to columns, it turns the two separate columns into one long vertical column and then adds the scroll bar. This can't be right?

Thanks,
Paul

darrellmeyer
18 Sep 2008, 8:41 PM
Please post complete test code and I will take a look. At first glance, I noticed you are setting the height of panel which is incorrect. myWindow is the parent container with a FitLayout, so it should have its height set. Also, if using FitLayout, the container with the layout should have a height as well.

You can also take a look at the form example code as there is an example using a 2 column layout.