01-20-2011 03:59 PM
I should also add that I don't understand how the layout manager decides what to do if there is more than 100% total size requested. In my example above, if I just use "new Spacer()" instead of "new Spacer(37.5)", each Spacer would request 100% of the total vertical space. myButton then winds up being very small vertically. I'm not sure how its size is decided. Does anyone know? The documentation says nothing about the layout algorithms, and in the documentation they purposefully request more than 100% of the total available flow.
01-20-2011 04:05 PM
simple answer: you can't. complex answer: you can but you have to be crafty. kind of like the way you stated about trying to add multiple containers. the container is kind of "dumb". it only positions things in a certain direction. when it comes to the opposite direction it burns out in my opinion. since in your code its only worrying about the vertical positioning of things, its not worrying too much about whats happening horizontally because its not placing anything next to your button. only things beneath it. its assuming there is nothing and will be nothing next to ur UIComponent (button).
01-20-2011 04:11 PM
just saw your question about spacing and the algorithm. im not going to pretend i know the algorithm of the container cause i dont. wish they made the code behind it more obvious but much like how its hitting u, we have to guess and check. my guess here is the developer has to be a little intuitive and know how many objects they are putting into the flow and how much room they really want to take up. in the documentation they used a space of 100% to show that you can "push" your objects in the opposite direction without explicitly saying "right align" the object.
now with all that being said im not at all a fan of the container class. im gonna go ahead and say i dont use it because its way too much work for me. id rather do my own calculations then have it do it for me. whether or not i am losing time, for me its more about convenience. i dislike it when i expect one thing to happen but a whole different thing happens. but thats just my view. the downside of my "conveneince" is the lack of support for possible resizing of the screen. but i'll take that on once it becomes a problem.
01-20-2011 04:20 PM
That is good to know! I was struggling to figure out what the intended "best practices" are for the use of containers. I can see that they sort of allow us to use percentages instead of fixed sizes, but it takes a lot of work and nested containers in order to do that. I don't like the notion of purposefully asking for more than 100% space to allow components to be pushed around, because that seems like an implementation that might break in the future. I'll think about using containers, but it just seems much easier and more controllable to use setSize and setPosition on each component. Thanks!