Example usage for java.awt Component setBounds

List of usage examples for java.awt Component setBounds

Introduction

In this page you can find the example usage for java.awt Component setBounds.

Prototype

public void setBounds(int x, int y, int width, int height) 

Source Link

Document

Moves and resizes this component.

Usage

From source file:org.omegat.gui.align.AlignPanelController.java

private static void resizeRows(JTable table) {
    for (int row = 0; row < table.getRowCount(); row++) {
        int max = 0;
        for (int col = BeadTableModel.COL_SRC; col < table.getColumnCount(); col++) {
            int colWidth = table.getColumnModel().getColumn(col).getWidth();
            TableCellRenderer cellRenderer = table.getCellRenderer(row, col);
            Component c = table.prepareRenderer(cellRenderer, row, col);
            c.setBounds(0, 0, colWidth, Integer.MAX_VALUE);
            int height = c.getPreferredSize().height;
            max = Math.max(max, height);
        }/* ww  w  .j a  va2s .c om*/
        table.setRowHeight(row, max);
    }
}

From source file:Main.java

public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    int maxWidth = parent.getWidth() - (insets.left + insets.right);
    int maxHeight = parent.getHeight() - (insets.top + insets.bottom);
    int nComps = parent.getComponentCount();
    int previousWidth = 0, previousHeight = 0;
    int x = 0, y = insets.top;
    int rowh = 0, start = 0;
    int xFudge = 0, yFudge = 0;
    boolean oneColumn = false;

    // Go through the components' sizes, if neither
    // preferredLayoutSize nor minimumLayoutSize has
    // been called.
    if (sizeUnknown) {
        setSizes(parent);/*from  ww w.  j a  v a2  s .  co m*/
    }

    if (maxWidth <= minWidth) {
        oneColumn = true;
    }

    if (maxWidth != preferredWidth) {
        xFudge = (maxWidth - preferredWidth) / (nComps - 1);
    }

    if (maxHeight > preferredHeight) {
        yFudge = (maxHeight - preferredHeight) / (nComps - 1);
    }

    for (int i = 0; i < nComps; i++) {
        Component c = parent.getComponent(i);
        if (c.isVisible()) {
            Dimension d = c.getPreferredSize();

            // increase x and y, if appropriate
            if (i > 0) {
                if (!oneColumn) {
                    x += previousWidth / 2 + xFudge;
                }
                y += previousHeight + vgap + yFudge;
            }

            // If x is too large,
            if ((!oneColumn) && (x + d.width) > (parent.getWidth() - insets.right)) {
                // reduce x to a reasonable number.
                x = parent.getWidth() - insets.bottom - d.width;
            }

            // If y is too large,
            if ((y + d.height) > (parent.getHeight() - insets.bottom)) {
                // do nothing.
                // Another choice would be to do what we do to x.
            }

            // Set the component's size and position.
            c.setBounds(x, y, d.width, d.height);

            previousWidth = d.width;
            previousHeight = d.height;
        }
    }
}

From source file:VerticalLayout.java

/**
 * Lays out the container./* w ww  . ja v a 2  s .c om*/
 */
public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    synchronized (parent.getTreeLock()) {
        int n = parent.getComponentCount();
        Dimension pd = parent.getSize();
        int y = 0;
        //work out the total size
        for (int i = 0; i < n; i++) {
            Component c = parent.getComponent(i);
            Dimension d = c.getPreferredSize();
            y += d.height + vgap;
        }
        y -= vgap; //otherwise there's a vgap too many
        //Work out the anchor paint
        if (anchor == TOP)
            y = insets.top;
        else if (anchor == CENTER)
            y = (pd.height - y) / 2;
        else
            y = pd.height - y - insets.bottom;
        //do layout
        for (int i = 0; i < n; i++) {
            Component c = parent.getComponent(i);
            Dimension d = c.getPreferredSize();
            int x = insets.left;
            int wid = d.width;
            if (alignment == CENTER)
                x = (pd.width - d.width) / 2;
            else if (alignment == RIGHT)
                x = pd.width - d.width - insets.right;
            else if (alignment == BOTH)
                wid = pd.width - insets.left - insets.right;
            c.setBounds(x, y, wid, d.height);
            y += d.height + vgap;
        }
    }
}

From source file:CenterLayout.java

public void layoutContainer(Container container) {
    int count = container.getComponentCount();
    if (count > 0) {
        Component child = container.getComponent(0);
        java.awt.Insets insets = container.getInsets();
        int availWidth = container.getWidth() - insets.left - insets.right;
        int availHeight = container.getHeight() - insets.top - insets.bottom;
        Dimension preferredSize = child.getPreferredSize();
        double preferredWidth = preferredSize.getWidth();
        double preferredHeight = preferredSize.getHeight();
        int width;
        int height;
        int x;/*from  w  ww .j a  va 2s .c om*/
        int y;
        if (preferredWidth < availWidth) {
            x = (int) Math.round(insets.left + (availWidth - preferredWidth) / 2);
            width = (int) Math.round(preferredWidth);
        } else {
            x = insets.left;
            width = availWidth;
        }
        if (preferredHeight < availHeight) {
            y = (int) Math.round(insets.top + (availHeight - preferredHeight) / 2);
            height = (int) Math.round(preferredHeight);
        } else {
            y = insets.top;
            height = availHeight;
        }
        child.setBounds(x, y, width, height);
    }
}

From source file:TableLayout.java

/**
 * Lays out the specified container. Throws an
 * <code>IllegalStateException</code> if any of the components added via the
 * <code>addLayoutComponent</code> method have a different parent than the
 * specified Container.//w  w w .  j  a  v  a 2 s .co  m
 */

public void layoutContainer(Container parent) {
    synchronized (parent.getTreeLock()) {
        int rowCount = rows.size();

        Insets parentInsets = parent.getInsets();

        // Collect the preferred sizes.
        Dimension[][] prefSizes = getPreferredSizes(parent);
        Pair layout = calculateLayout(prefSizes);
        int[] columnWidths = (int[]) layout.getFirst();
        int[] rowHeights = (int[]) layout.getSecond();

        Dimension prefParentSize = calculatePreferredLayoutSize(parent, columnWidths, rowHeights);
        Dimension parentSize = parent.getSize();
        Dimension layoutSize = new Dimension(
                parentSize.width - xGap * (rowCount - 1) - parentInsets.left - parentInsets.right,
                parentSize.height - yGap * (columnCount - 1) - parentInsets.top - parentInsets.bottom);
        Dimension prefLayoutSize = new Dimension(
                prefParentSize.width - xGap * (rowCount - 1) - parentInsets.left - parentInsets.right,
                prefParentSize.height - yGap * (columnCount - 1) - parentInsets.top - parentInsets.bottom);

        // Layout the components.
        int y = parentInsets.top;
        for (int i = 0; i < rowCount; i++) {
            int x = parentInsets.left;
            int cellHeight = (rowHeights[i] * layoutSize.height) / prefLayoutSize.height;
            Component[] row = (Component[]) rows.elementAt(i);
            for (int j = 0; j < row.length; j++) {
                int cellWidth = (columnWidths[j] * layoutSize.width) / prefLayoutSize.width;
                Component component = row[j];

                // Can only happen on the last line when all the remaining components are null as well
                if (component == null)
                    break;

                Dimension maxSize = component.getMaximumSize();

                int compWidth = Math.min(maxSize.width, cellWidth);
                int compHeight = Math.min(maxSize.height, cellHeight);

                int compX = x + (int) ((cellWidth - compWidth) * component.getAlignmentX());
                int compY = y + (int) ((cellHeight - compHeight) * component.getAlignmentY());

                component.setBounds(compX, compY, compWidth, compHeight);

                x += cellWidth + xGap;
            }

            y += cellHeight + yGap;
        }
    }
}

From source file:FunLayout.java

public void layoutContainer(Container con) {
    int i, count, deltax, deltay, move;
    Dimension conSize;//from   w ww  .j  a va  2 s  . c o m
    Rectangle rect;
    Component comp;

    conSize = con.getSize();
    if (_prevContainerSize == null) {
        _prevContainerSize = conSize;
        return;
    }
    deltax = conSize.width - _prevContainerSize.width;
    deltay = conSize.height - _prevContainerSize.height;
    _prevContainerSize = conSize;
    count = con.countComponents();
    for (i = 0; i < count; i++) {
        comp = con.getComponent(i);
        if (!comp.isVisible())
            continue;
        move = _getMove(comp);
        if (move == 0)
            continue;
        rect = comp.getBounds();
        if (_negSized.containsKey(comp)) {
            // the component is really at a negative size
            rect = (Rectangle) _negSized.get(comp);
            _negSized.remove(comp);
        }
        if ((move & MOVES_RIGHT) > 0)
            rect.x += deltax;
        else if ((move & WIDTH_CHANGES) > 0)
            rect.width += deltax;
        if ((move & MOVES_DOWN) > 0)
            rect.y += deltay;
        else if ((move & HEIGHT_CHANGES) > 0)
            rect.height += deltay;
        // if a components size becomes negative, we track it since the AWT
        // does not allow components to have a size < (0, 0)
        if (rect.width < 0 || rect.height < 0)
            _negSized.put(comp, rect);
        comp.setBounds(rect.x, rect.y, rect.width, rect.height);
    }
}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

protected boolean installEditor(final ReportElementInlineEditor inlineEditor, final Element element) {
    if (inlineEditor == null) {
        throw new NullPointerException();
    }/*from   www .  j a va2  s  . co  m*/

    this.inlineEditor = inlineEditor;

    final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
    if (data == null) {
        removeEditor();
        return false;
    }
    final Component editorComponent = inlineEditor.getElementCellEditorComponent(this, element);
    if (editorComponent == null) {
        removeEditor();
        return false;
    }

    if (editorRemover == null) {
        final KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        editorRemover = new CellEditorRemover(fm);
        fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NON-NLS
    }

    this.editorComponent = editorComponent;

    final float zoomFactor = getRenderContext().getZoomModel().getZoomAsPercentage();

    final Rectangle2D bounds = getElementRenderer().getBounds();
    final int x = (int) ((getLeftBorder() + StrictGeomUtility.toExternalValue(data.getX())) * zoomFactor);
    final int y = (int) ((getTopBorder()
            + (StrictGeomUtility.toExternalValue(data.getY()) - bounds.getY()) * zoomFactor));
    final int width = (int) (StrictGeomUtility.toExternalValue(data.getWidth()) * zoomFactor);
    final int height = (int) (StrictGeomUtility.toExternalValue(data.getHeight()) * zoomFactor);
    editorComponent.setBounds(x, y, width, height);
    add(editorComponent);
    editorComponent.validate();
    inlineEditor.addCellEditorListener(this);

    List<Element> selectedElements = getRenderContext().getSelectionModel()
            .getSelectedElementsOfType(Element.class);
    final Element[] visualElements = selectedElements.toArray(new Element[selectedElements.size()]);
    if (visualElements.length > 0) {
        oldValues = new ArrayList<Object>();
        for (int i = 0; i < visualElements.length; i++) {
            final Object attribute = visualElements[i].getAttribute(AttributeNames.Core.NAMESPACE,
                    AttributeNames.Core.VALUE);
            oldValues.add(attribute);
        }
    }

    return true;
}

From source file:EdgeLayoutExample.java

public void layoutContainer(Container parent) {
    synchronized (parent.getTreeLock()) {
        Insets insets = parent.getInsets();
        int top = insets.top;
        int left = insets.left;

        Dimension minimumSize = minimumLayoutSize(parent);

        int height = minimumSize.height;
        int width = minimumSize.width;

        int availableHeight = parent.getHeight() - insets.bottom - insets.top;
        int availableWidth = parent.getWidth() - insets.left - insets.right;
        if (height < availableHeight) {
            height = availableHeight;//from  w w w . j  a va  2  s. c  om
        }
        if (width < availableWidth) {
            width = availableWidth;
        }

        int bottom = availableHeight;
        int right = availableWidth;

        Dimension preferredSize = preferredLayoutSize(parent);

        int preferredWidthAvailable = width - preferredSize.width;
        int preferredHeightAvailable = height - preferredSize.height;

        Component centerComp = null;

        for (int i = 0; i < this.components.size(); i++) {
            Component c = (Component) this.components.get(i);
            String constraint = (String) this.constraints.get(c);

            if (constraint.equals(CENTER)) {
                centerComp = c;
            } else {
                int compHeight;
                int compWidth;
                int xOrigin;
                int yOrigin;

                if (constraint.equals(NORTH) || constraint.equals(SOUTH)) {
                    compWidth = width;

                    if (preferredHeightAvailable > 0) {
                        int preferredHeightNeeded = c.getPreferredSize().height - c.getMinimumSize().height;
                        if (preferredHeightAvailable > preferredHeightNeeded) {
                            compHeight = c.getPreferredSize().height;
                            preferredHeightAvailable -= preferredHeightNeeded;
                        } else {
                            compHeight = c.getMinimumSize().height + preferredHeightAvailable;
                            preferredHeightAvailable = 0;
                        }
                    } else {
                        compHeight = c.getMinimumSize().height;
                    }
                    height = height - compHeight;

                    xOrigin = left;

                    if (constraint.equals(NORTH)) {
                        yOrigin = top;
                        top += compHeight;
                    } else {
                        yOrigin = bottom - compHeight;
                        bottom = yOrigin;
                    }
                } else {
                    compHeight = height;
                    if (preferredWidthAvailable > 0) {
                        int preferredWidthNeeded = c.getPreferredSize().width - c.getMinimumSize().width;
                        if (preferredWidthAvailable > preferredWidthNeeded) {
                            compWidth = c.getPreferredSize().width;
                            preferredWidthAvailable -= preferredWidthNeeded;
                        } else {
                            compWidth = c.getMinimumSize().width + preferredWidthAvailable;
                            preferredWidthAvailable = 0;
                        }
                    } else {
                        compWidth = c.getMinimumSize().width;
                    }
                    width = width - compWidth;

                    yOrigin = top;

                    if (constraint.equals(WEST)) {
                        xOrigin = left;
                        left += compWidth;
                    } else {
                        xOrigin = right - compWidth;
                        right = xOrigin;
                    }
                }
                c.setSize(compWidth, compHeight);
                c.setBounds(xOrigin, yOrigin, compWidth, compHeight);
            }
            if (centerComp != null) {
                c.setSize(width, height);
                c.setBounds(left, top, width, height);
            }
        }
    }
}

From source file:TableLayout.java

public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    measureComponents(parent);/*from w  w  w. ja  v a  2  s .  com*/
    int width = parent.getSize().width - (insets.left + insets.right);
    int height = parent.getSize().height - (insets.top + insets.bottom);
    // System.out.println("Resize "+width+","+height);

    // Decide whether to base our scaling on minimum or preferred sizes, or
    // a mixture of both, separately for width and height scaling.
    // This weighting also tells us how much of the hgap/vgap to use.

    double widthWeighting = 0.0;
    if (width >= PrefWidth || PrefWidth == MinWidth)
        widthWeighting = 1.0;
    else if (width <= MinWidth) {
        widthWeighting = 0.0;
        width = MinWidth;
    } else
        widthWeighting = (double) (width - MinWidth) / (double) (PrefWidth - MinWidth);

    double heightWeighting = 0.0;
    if (height >= PrefHeight || PrefHeight == MinHeight)
        heightWeighting = 1.0;
    else if (height <= MinHeight) {
        heightWeighting = 0.0;
        height = MinHeight;
    } else
        heightWeighting = (double) (height - MinHeight) / (double) (PrefHeight - MinHeight);

    // calculate scale factors to scale components to size of container, based
    // on weighted combination of minimum and preferred sizes

    double minWidthScale = (1.0 - widthWeighting) * width / MinWidth;
    //double prefWidthScale = widthWeighting * (width-hgap*(ncols+1))/(PrefWidth-hgap*(ncols+1));
    double minHeightScale = (1.0 - heightWeighting) * height / MinHeight;
    double prefHeightScale = heightWeighting * (height - vgap * (nrows + 1))
            / (PrefHeight - vgap * (nrows + 1));

    // only get the full amount of gap if we're working to preferred size
    int vGap = (int) (vgap * heightWeighting);
    int hGap = (int) (hgap * widthWeighting);

    int y = insets.top + vGap;

    for (int c = 0; c < ncols; ++c)
        weight[c] = prefWidth[c];

    for (int r = 0; r < nrows; ++r) {
        int x = insets.left + hGap;
        int rowHeight = (int) (minHeight[r] * minHeightScale + prefHeight[r] * prefHeightScale);

        // Column padding can vary from row to row, so we need several
        // passes through the columns for each row:

        // First, work out the weighting that deterimines how we distribute column padding
        for (int c = 0; c < ncols; ++c) {
            Component comp = components[c][r];
            if (comp != null) {
                TableOption option = (TableOption) options.get(comp);
                if (option == null)
                    option = defaultOption;
                if (option.weight >= 0)
                    weight[c] = option.weight;
                else if (option.weight == -1)
                    weight[c] = prefWidth[c];
            }
        }
        int totalWeight = 0;
        for (int c = 0; c < ncols; ++c)
            totalWeight += weight[c];
        int horizSurplus = width - hgap * (ncols + 1) - PrefWidth;

        // Then work out column sizes, essentially preferred size + share of padding
        for (int c = 0; c < ncols; ++c) {
            columnWidth[c] = (int) (minWidthScale * minWidth[c] + widthWeighting * prefWidth[c]);
            if (horizSurplus > 0 && totalWeight > 0)
                columnWidth[c] += (int) (widthWeighting * horizSurplus * weight[c] / totalWeight);
        }

        // Only now do we know enough to position all the columns within this row...
        for (int c = 0; c < ncols; ++c) {
            Component comp = components[c][r];
            if (comp != null) {
                TableOption option = (TableOption) options.get(comp);
                if (option == null)
                    option = defaultOption;

                // cell size may be bigger than row/column size due to spanning
                int cellHeight = rowHeight;
                int cellWidth = columnWidth[c];
                for (int i = 1; i < option.colSpan; ++i)
                    cellWidth += columnWidth[c + i];
                for (int i = 1; i < option.rowSpan; ++i)
                    cellHeight += (int) (minHeight[r + i] * minHeightScale + prefHeight[r + i] * prefHeightScale
                            + vGap);

                Dimension d = new Dimension(comp.getPreferredSize());

                if (d.width > cellWidth || option.horizontal == TableOption.FILL)
                    d.width = cellWidth;
                if (d.height > cellHeight || option.vertical == TableOption.FILL)
                    d.height = cellHeight;

                int yoff = 0;
                if (option.vertical == TableOption.BOTTOM)
                    yoff = cellHeight - d.height;
                else if (option.vertical == TableOption.CENTRE)
                    yoff = (cellHeight - d.height) / 2;

                int xoff = 0;
                if (option.horizontal == TableOption.RIGHT)
                    xoff = cellWidth - d.width;
                else if (option.horizontal == TableOption.CENTRE)
                    xoff = (cellWidth - d.width) / 2;

                // System.out.println(" "+comp.getClass().getName()+" at ("+x+"+"+xoff+","+y+"+"+yoff+"), size "+d.width+","+d.height);
                comp.setBounds(x + xoff, y + yoff, d.width, d.height);
            }
            x += columnWidth[c] + hGap;
        }
        y += rowHeight + vGap;
    }
}

From source file:FormatLayout.java

/**
 * Performs the layout of the container.
 *
 * @param parent  the parent.//from w ww.j  a va2 s  . c  o m
 */
public void layoutContainer(final Container parent) {
    Component c0, c1, c2, c3, c4, c5;

    synchronized (parent.getTreeLock()) {
        final Insets insets = parent.getInsets();
        int componentIndex = 0;
        final int rowCount = this.rowHeights.length;
        for (int i = 0; i < this.columnWidths.length; i++) {
            this.columnWidths[i] = 0;
        }
        this.columns1and2Width = 0;
        this.columns4and5Width = 0;
        this.columns1to4Width = 0;
        this.columns1to5Width = 0;
        this.columns0to5Width = parent.getBounds().width - insets.left - insets.right;

        this.totalHeight = 0;
        for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
            final int format = this.rowFormats[rowIndex % this.rowFormats.length];
            switch (format) {
            case FormatLayout.C:
                c0 = parent.getComponent(componentIndex);
                updateC(rowIndex, c0.getPreferredSize());
                componentIndex = componentIndex + 1;
                break;
            case FormatLayout.LC:
                c0 = parent.getComponent(componentIndex);
                c1 = parent.getComponent(componentIndex + 1);
                updateLC(rowIndex, c0.getPreferredSize(), c1.getPreferredSize());
                componentIndex = componentIndex + 2;
                break;
            case FormatLayout.LCB:
                c0 = parent.getComponent(componentIndex);
                c1 = parent.getComponent(componentIndex + 1);
                c2 = parent.getComponent(componentIndex + 2);
                updateLCB(rowIndex, c0.getPreferredSize(), c1.getPreferredSize(), c2.getPreferredSize());
                componentIndex = componentIndex + 3;
                break;
            case FormatLayout.LCLC:
                c0 = parent.getComponent(componentIndex);
                c1 = parent.getComponent(componentIndex + 1);
                c2 = parent.getComponent(componentIndex + 2);
                c3 = parent.getComponent(componentIndex + 3);
                updateLCLC(rowIndex, c0.getPreferredSize(), c1.getPreferredSize(), c2.getPreferredSize(),
                        c3.getPreferredSize());
                componentIndex = componentIndex + 4;
                break;
            case FormatLayout.LCBLC:
                c0 = parent.getComponent(componentIndex);
                c1 = parent.getComponent(componentIndex + 1);
                c2 = parent.getComponent(componentIndex + 2);
                c3 = parent.getComponent(componentIndex + 3);
                c4 = parent.getComponent(componentIndex + 4);
                updateLCBLC(rowIndex, c0.getPreferredSize(), c1.getPreferredSize(), c2.getPreferredSize(),
                        c3.getPreferredSize(), c4.getPreferredSize());
                componentIndex = componentIndex + 5;
                break;
            case FormatLayout.LCLCB:
                c0 = parent.getComponent(componentIndex);
                c1 = parent.getComponent(componentIndex + 1);
                c2 = parent.getComponent(componentIndex + 2);
                c3 = parent.getComponent(componentIndex + 3);
                c4 = parent.getComponent(componentIndex + 4);
                updateLCLCB(rowIndex, c0.getPreferredSize(), c1.getPreferredSize(), c2.getPreferredSize(),
                        c3.getPreferredSize(), c4.getPreferredSize());
                componentIndex = componentIndex + 5;
                break;
            case FormatLayout.LCBLCB:
                c0 = parent.getComponent(componentIndex);
                c1 = parent.getComponent(componentIndex + 1);
                c2 = parent.getComponent(componentIndex + 2);
                c3 = parent.getComponent(componentIndex + 3);
                c4 = parent.getComponent(componentIndex + 4);
                c5 = parent.getComponent(componentIndex + 5);
                updateLCBLCB(rowIndex, c0.getPreferredSize(), c1.getPreferredSize(), c2.getPreferredSize(),
                        c3.getPreferredSize(), c4.getPreferredSize(), c5.getPreferredSize());
                componentIndex = componentIndex + 6;
                break;
            }
        }
        complete();

        componentIndex = 0;
        int rowY = insets.top;
        final int[] rowX = new int[6];
        rowX[0] = insets.left;
        rowX[1] = rowX[0] + this.columnWidths[0] + this.columnGaps[0];
        rowX[2] = rowX[1] + this.columnWidths[1] + this.columnGaps[1];
        rowX[3] = rowX[2] + this.columnWidths[2] + this.columnGaps[2];
        rowX[4] = rowX[3] + this.columnWidths[3] + this.columnGaps[3];
        rowX[5] = rowX[4] + this.columnWidths[4] + this.columnGaps[4];
        final int w1to2 = this.columnWidths[1] + this.columnGaps[1] + this.columnWidths[2];
        final int w4to5 = this.columnWidths[4] + this.columnGaps[4] + this.columnWidths[5];
        final int w1to4 = w1to2 + this.columnGaps[2] + this.columnWidths[3] + this.columnGaps[3]
                + this.columnWidths[4];
        final int w1to5 = w1to4 + this.columnGaps[4] + this.columnWidths[5];
        final int w0to5 = w1to5 + this.columnWidths[0] + this.columnGaps[0];
        for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
            final int format = this.rowFormats[rowIndex % this.rowFormats.length];

            switch (format) {
            case FormatLayout.C:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY, w0to5, c0.getPreferredSize().height);
                componentIndex = componentIndex + 1;
                break;
            case FormatLayout.LC:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY + (this.rowHeights[rowIndex] - c0.getPreferredSize().height) / 2,
                        this.columnWidths[0], c0.getPreferredSize().height);
                c1 = parent.getComponent(componentIndex + 1);
                c1.setBounds(rowX[1], rowY + (this.rowHeights[rowIndex] - c1.getPreferredSize().height) / 2,
                        w1to5, c1.getPreferredSize().height);
                componentIndex = componentIndex + 2;
                break;
            case FormatLayout.LCB:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY + (this.rowHeights[rowIndex] - c0.getPreferredSize().height) / 2,
                        this.columnWidths[0], c0.getPreferredSize().height);
                c1 = parent.getComponent(componentIndex + 1);
                c1.setBounds(rowX[1], rowY + (this.rowHeights[rowIndex] - c1.getPreferredSize().height) / 2,
                        w1to4, c1.getPreferredSize().height);
                c2 = parent.getComponent(componentIndex + 2);
                c2.setBounds(rowX[5], rowY + (this.rowHeights[rowIndex] - c2.getPreferredSize().height) / 2,
                        this.columnWidths[5], c2.getPreferredSize().height);
                componentIndex = componentIndex + 3;
                break;
            case FormatLayout.LCLC:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY + (this.rowHeights[rowIndex] - c0.getPreferredSize().height) / 2,
                        this.columnWidths[0], c0.getPreferredSize().height);
                c1 = parent.getComponent(componentIndex + 1);
                c1.setBounds(rowX[1], rowY + (this.rowHeights[rowIndex] - c1.getPreferredSize().height) / 2,
                        w1to2, c1.getPreferredSize().height);
                c2 = parent.getComponent(componentIndex + 2);
                c2.setBounds(rowX[3], rowY + (this.rowHeights[rowIndex] - c2.getPreferredSize().height) / 2,
                        this.columnWidths[3], c2.getPreferredSize().height);
                c3 = parent.getComponent(componentIndex + 3);
                c3.setBounds(rowX[4], rowY + (this.rowHeights[rowIndex] - c3.getPreferredSize().height) / 2,
                        w4to5, c3.getPreferredSize().height);
                componentIndex = componentIndex + 4;
                break;
            case FormatLayout.LCBLC:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY + (this.rowHeights[rowIndex] - c0.getPreferredSize().height) / 2,
                        this.columnWidths[0], c0.getPreferredSize().height);
                c1 = parent.getComponent(componentIndex + 1);
                c1.setBounds(rowX[1], rowY + (this.rowHeights[rowIndex] - c1.getPreferredSize().height) / 2,
                        this.columnWidths[1], c1.getPreferredSize().height);
                c2 = parent.getComponent(componentIndex + 2);
                c2.setBounds(rowX[2], rowY + (this.rowHeights[rowIndex] - c2.getPreferredSize().height) / 2,
                        this.columnWidths[2], c2.getPreferredSize().height);
                c3 = parent.getComponent(componentIndex + 3);
                c3.setBounds(rowX[3], rowY + (this.rowHeights[rowIndex] - c3.getPreferredSize().height) / 2,
                        this.columnWidths[3], c3.getPreferredSize().height);
                c4 = parent.getComponent(componentIndex + 4);
                c4.setBounds(rowX[4], rowY + (this.rowHeights[rowIndex] - c4.getPreferredSize().height) / 2,
                        w4to5, c4.getPreferredSize().height);
                componentIndex = componentIndex + 5;
                break;
            case FormatLayout.LCLCB:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY + (this.rowHeights[rowIndex] - c0.getPreferredSize().height) / 2,
                        this.columnWidths[0], c0.getPreferredSize().height);
                c1 = parent.getComponent(componentIndex + 1);
                c1.setBounds(rowX[1], rowY + (this.rowHeights[rowIndex] - c1.getPreferredSize().height) / 2,
                        w1to2, c1.getPreferredSize().height);
                c2 = parent.getComponent(componentIndex + 2);
                c2.setBounds(rowX[3], rowY + (this.rowHeights[rowIndex] - c2.getPreferredSize().height) / 2,
                        this.columnWidths[3], c2.getPreferredSize().height);
                c3 = parent.getComponent(componentIndex + 3);
                c3.setBounds(rowX[4], rowY + (this.rowHeights[rowIndex] - c3.getPreferredSize().height) / 2,
                        this.columnWidths[4], c3.getPreferredSize().height);
                c4 = parent.getComponent(componentIndex + 4);
                c4.setBounds(rowX[5], rowY + (this.rowHeights[rowIndex] - c4.getPreferredSize().height) / 2,
                        this.columnWidths[5], c4.getPreferredSize().height);
                componentIndex = componentIndex + 5;
                break;
            case FormatLayout.LCBLCB:
                c0 = parent.getComponent(componentIndex);
                c0.setBounds(rowX[0], rowY + (this.rowHeights[rowIndex] - c0.getPreferredSize().height) / 2,
                        this.columnWidths[0], c0.getPreferredSize().height);
                c1 = parent.getComponent(componentIndex + 1);
                c1.setBounds(rowX[1], rowY + (this.rowHeights[rowIndex] - c1.getPreferredSize().height) / 2,
                        this.columnWidths[1], c1.getPreferredSize().height);
                c2 = parent.getComponent(componentIndex + 2);
                c2.setBounds(rowX[2], rowY + (this.rowHeights[rowIndex] - c2.getPreferredSize().height) / 2,
                        this.columnWidths[2], c2.getPreferredSize().height);
                c3 = parent.getComponent(componentIndex + 3);
                c3.setBounds(rowX[3], rowY + (this.rowHeights[rowIndex] - c3.getPreferredSize().height) / 2,
                        this.columnWidths[3], c3.getPreferredSize().height);
                c4 = parent.getComponent(componentIndex + 4);
                c4.setBounds(rowX[4], rowY + (this.rowHeights[rowIndex] - c4.getPreferredSize().height) / 2,
                        this.columnWidths[4], c4.getPreferredSize().height);
                c5 = parent.getComponent(componentIndex + 5);
                c5.setBounds(rowX[5], rowY + (this.rowHeights[rowIndex] - c5.getPreferredSize().height) / 2,
                        this.columnWidths[5], c5.getPreferredSize().height);
                componentIndex = componentIndex + 6;
                break;
            }
            rowY = rowY + this.rowHeights[rowIndex] + this.rowGap;
        }
    }
}