next up previous contents index
Next: The table constraint Up: Layout constraints Previous: The sameXXX constraint

The grid constraint

The grid constraint grid(DJComponent[][] comps) takes a two-dimensional array of components comps and ensures that the components are placed in a grid board. Suppose the array comps is $m\times n$. Then, the grid board is $m\times n$ and each grid (i,j) is covered by the component comps[i][j]. Notice that a component can cover several consecutive grids if it appears in the array several times.  

For example, the following program displays the panel shown in Figure [*].

     class TestGrid {
            dj Button bt[5];
            for (i in 0..4) bt[i].text == String(i);
            grid({{bt[0],bt[0],bt[1]},
                  {bt[3],bt[4],bt[1]},
                  {bt[3],bt[2],bt[2]}});
      }


  
Figure: Grid constraint.
\begin{figure}
\begin{center}
\epsfile{file=grid.ps,width=3cm}\end{center}\end{figure}



Neng-Fa Zhou
1999-02-16