Using absolute cell coordinates – MiG InfoCom MiG Layout Quick Start Guide User Manual

Page 2

Advertising
background image

panel.add(comp1);
panel.add(comp2, "span 2 2"); // The component will span 2x2 cells.
panel.add(comp3, "wrap"); // Wrap to next row
panel.add(comp4);
panel.add(comp5, "wrap"); // Note that it "jumps over" the occupied cells.
panel.add(comp6);
panel.add(comp7);

comp1

comp4

comp2

comp3

comp5

comp6

comp7

It is equally easy and intuitive to split cells.

panel.add(comp1);
panel.add(comp2, "split 2"); // Split the cell in two
panel.add(comp3); // Will be in same cell as previous
panel.add(comp4, "wrap"); // Wrap to next row
panel.add(comp5);

comp1

comp2 comp3

comp4

comp5

It is of course possible to both span and split cells at the same time. You can for instance span three cells
and split that three-cell-wide cell into two.

Using Absolute Cell Coordinates

If you don't want to use the "flow" way to put components into grid positions you can instead use absolute
coordinates. For instance:

panel.add(comp1, "cell 0 0"); // "cell column row"
panel.add(comp2, "cell 1 0");
panel.add(comp3, "cell 2 0");
panel.add(comp4, "cell 0 1");

Would produce the same grid as the first example at the top.

comp1

comp2

comp3

comp4

You can also use the absolute cell way to span and split cells. If a component is put in a cell that already has
a component the cell will be split and both cells will end up in the same cell, sharing its space. To make the
same grid as the second example above you do like this:

© 2009 MiG InfoCom AB

Advertising