com.bolthole.flexilayout - a java LayoutManager class

This is the home page for the flexilayout LayoutManager.

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.

flexilayout snapshot

DESCRIPTION

flexilayout is a medium complexity layout manager, that allows for much more freedom than most of the standard LayoutManagers, while hopefully being easier to understand than GridBagLayout

Drawbacks

If you want stuff to scale itself to fill a window as it is resized, this is not the appropriate LayoutManager for you

Advantages

If you want your windows to be able to grow/shrink based on the size of what is being displayed, this IS for you. [Just call Frame.pack() or whatever is aprropriate for your top level]

USAGE

You have to first create one or more components and fix them to have absolute pixel positioning. You can then position other objects relative to the initial one.

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()


Downloads

If you want to grab a .jar file and start playing, click on flexilayout.jar. Remember to add flexilayout.jar to your CLASSPATH, and access the class via com.bolthole.flexilayout

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! [email protected]

Bolthole.com