The <compactgrid> Tag

The <compactgrid> tag creates a container for other components. The components are displayed in a grid with a given number of rows or columns. Components are added to the uppermost available row from left-to-right. For a compact grid to be displayed correctly, every row must be completely filled.

In a compact grid, each cell retains its normal height and at least its normal width. Cell widths are adjusted to match the width of the largest component in each column (similar to the strategy used in HTML tables). If there is extra space, it is distributed evenly among all columns.

Parameters

Either the rows or cols parameter must be specified.

Name Description Legal Values Default
cols

The number of columns in the grid. If this parameter is left blank, the value will be calculated based on the rows parameter and the number of components that have been added.

any positive integer

automatically calculate based on rows parameter

rows

The number of rows in the grid. If this parameter is left blank, the value will be calculated based on the cols parameter and the number of components that have been added.

any positive integer

automatically calculate based on cols parameter

ypad

The number of pixels of space to place above and below each component.

any positive integer

0
xpad

The number of pixels of space to place to either side of each component.

any positive integer

0

Also see common parameters .

Contents

The compactgrid tag contains tags representing the components that should be added to the compactgrid .

Example

In the following example, note the very different way that <compactgrid> and <grid> lay out the same collection of labels.

<xmllayout>
   <panel>
      <west>
         <component id="DAG"/>
      </west>
      <center>
         <grid rows="2" cols="1">
            <compactgrid cols="3">
               <label text="Current selection:"/>
               <spacer size="10"/>
               <label text="`if (GUI.getSubSelection() != null) return GUI.getSubSelection().getName(); else return '';`" foreground="red"/>
               <label text="Number of synonyms:"/>
               <spacer size="10"/>
               <label text="`if (GUI.getSubSelection() != null) return size(GUI.getSubSelection().getSynonyms()); else return '';`" font="Arial-BOLD-16" foreground="green"/>
               <label text="Number of dbxrefs:"/>
               <spacer size="10"/>
               <label text="`if (GUI.getSubSelection() != null) return size(GUI.getSubSelection().getDbxrefs()); else return '';`" font="Arial-BOLD-16" foreground="green"/>
            </compactgrid>

            <grid cols="3" rows="3">
               <label text="Current selection:"/>
               <spacer size="10"/>
               <label text="`if (GUI.getSubSelection() != null) return GUI.getSubSelection().getName(); else return '';`" foreground="red"/>
               <label text="Number of synonyms:"/>
               <spacer size="10"/>
               <label text="`if (GUI.getSubSelection() != null) return size(GUI.getSubSelection().getSynonyms()); else return '';`" font="Arial-BOLD-16" foreground="green"/>
               <label text="Number of dbxrefs:"/>
               <spacer size="10"/>
               <label text="`if (GUI.getSubSelection() != null) return size(GUI.getSubSelection().getDbxrefs()); else return '';`" font="Arial-BOLD-16" foreground="green"/>
            </grid>
         </grid>
      </center>
   </panel>
</xmllayout>