Here is an example of a single Panel, with a single flexilayout managing the five rectangles you see. You'll be hard pressed to find another layout manager that will let you have this degree of flexibility, with a relatively simple degree of setup.
The simplest thing to do is of course to set the first object at (0,0)
You can then position yet more objects relative to the secondary objects.
Possible relationships:
TileLeftOf, AlignLeft, AlignInsideLeft, Center TileRightOf, AlignRight, AlignInsideRight
eg: next to, in line with, or [inside, with a border].
Substitute "UpOf" or "DownOf" for "LeftOf" or "RightOf", as required.
Sample snippet:
mylayout=new com.bolthole.flexilayout(); panel=new Panel(mylayout); Button one=new Button("A long button"); Button two=new Button("centered"); panel.add(one); mylayout.setLocation(one,0,0); panel.add(two); mylayout.setConstraints(two, mylayout.Center, one, mylayout.TileDownOf,one);
Note that flexilayout will generally NOT change the size of contained objects at all, unless the size is 0x0. In that case, it will set the size to whatever the object returns via getMinimumSize()
Or if you want to dig at the source code, feel free to download the UNIX tar file
If you have any suggestions, comments, or "hey, it works on platform xxx,
cool", drop me a line!