Example usage for java.awt Container getComponents

List of usage examples for java.awt Container getComponents

Introduction

In this page you can find the example usage for java.awt Container getComponents.

Prototype

public Component[] getComponents() 

Source Link

Document

Gets all the components in this container.

Usage

From source file:StackLayout.java

private void layoutComponents(Container parent) {
    Component[] components = parent.getComponents();
    Insets in = parent.getInsets();

    int maxHeight = parent.getHeight() - in.top - in.bottom;
    int maxWidth = parent.getWidth() - in.left - in.right;
    boolean horiz = (ourOrientation == HORIZONTAL);

    int totalDepth = calculatePreferredDepth(components, ourOrientation);
    totalDepth = Math.max(totalDepth, (horiz ? maxHeight : maxWidth));

    int prefLength = (ourLengthsMatched ? calculateAdjustedLength(components, ourOrientation, ourSpacing)
            : calculatePreferredLength(components, ourOrientation, ourSpacing));
    int totalLength = Math.min(prefLength, (horiz ? maxWidth : maxHeight));

    int a = (horiz ? in.left : in.top);
    int b = (horiz ? in.top : in.left);
    int l = 0, d = 0, sum = 0;
    int matchedLength = 0;
    Dimension prefsize = null;//w  ww. j av  a 2 s  . c  o  m

    if (ourLengthsMatched) {
        matchedLength = (horiz ? getMaxPrefWidth(components) : getMaxPrefHeight(components));

        if (prefLength > totalLength && ourSqueezeFactor < 100) {
            int minLength = calculateMinimumLength(components, ourOrientation, ourSpacing);

            if (minLength >= totalLength) {
                matchedLength = (matchedLength * ourSqueezeFactor) / 100;
            }

            else {
                int numSeparators = countSeparators(components);
                int numComponents = components.length - numSeparators;
                int diff = (prefLength - totalLength) / numComponents;
                if ((prefLength - totalLength) % numComponents > 0)
                    diff++;
                matchedLength -= diff;
            }
        }
    }

    for (int i = 0; i < components.length; i++) {
        prefsize = components[i].getPreferredSize();
        if (!ourLengthsMatched)
            l = (horiz ? prefsize.width : prefsize.height);
        else
            l = matchedLength;

        if (components[i] instanceof JSeparator) {
            // l = Math.min(prefsize.width, prefsize.height);
            l = (horiz ? prefsize.width : prefsize.height);
            d = totalDepth;
            sum += l;
            if (ourDrop && sum > totalLength)
                l = 0;
        }

        else {
            sum += l;
            if (ourDrop && sum > totalLength)
                l = 0;

            else if (ourFill && !ourLengthsMatched && i == components.length - 1) {
                l = Math.max(l, (horiz ? maxWidth : maxHeight));
            }

            if (ourDepthsMatched)
                d = totalDepth;
            else
                d = (horiz ? prefsize.height : prefsize.width);
        }

        if (horiz)
            components[i].setBounds(a, b + (totalDepth - d) / 2, l, d);
        else
            components[i].setBounds(b + (totalDepth - d) / 2, a, d, l);

        a += l + ourSpacing;
        sum += ourSpacing;
    }

}

From source file:StackLayout.java

/**
 * Returns the preferred size for this layout to arrange the
 * indicated parent's children at the specified orientation.
 *///from w  ww  .  j a va2s.c  o  m
// public, because it's useful - not one of the LayoutManager methods
public Dimension preferredLayoutSize(Container parent, int orientation) {
    synchronized (parent.getTreeLock()) {
        Component[] comps = parent.getComponents();
        Dimension total = new Dimension(0, 0);

        int depth = calculatePreferredDepth(comps, orientation);

        int length = (ourLengthsMatched ? calculateAdjustedLength(comps, orientation, ourSpacing)
                : calculatePreferredLength(comps, orientation, ourSpacing));

        total.width = (orientation == HORIZONTAL ? length : depth);
        total.height = (orientation == HORIZONTAL ? depth : length);

        Insets in = parent.getInsets();
        total.width += in.left + in.right;
        total.height += in.top + in.bottom;

        return total;
    }
}

From source file:StackLayout.java

/**
 * Returns the minimum size for this layout to arrange the
 * indicated parent's children at the specified orientation.
 *///  w w  w .  j a v a 2s.  c  o  m
public Dimension minimumLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
        if (parent instanceof JToolBar) {
            setOrientation(((JToolBar) parent).getOrientation());
        }

        Component[] comps = parent.getComponents();
        Dimension total = new Dimension(0, 0);

        int depth = calculatePreferredDepth(comps, ourOrientation);
        int length = calculateMinimumLength(comps, ourOrientation, ourSpacing);

        total.width = (ourOrientation == HORIZONTAL ? length : depth);
        total.height = (ourOrientation == HORIZONTAL ? depth : length);

        Insets in = parent.getInsets();
        total.width += in.left + in.right;
        total.height += in.top + in.bottom;

        return total;
    }
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

private static void recursivelySetInheritsPopupMenu(Container container, boolean b) {
    if (container instanceof JComponent) {
        ((JComponent) container).setInheritsPopupMenu(b);
    }/*from w  w  w  . j a  v a 2s.  c o  m*/

    final Component[] components = container.getComponents();

    for (Component component : components) {
        recursivelySetInheritsPopupMenu((Container) component, b);
    }
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Recursively disables or enables all swing and awt components in this
 * dialog, starting with but not including the container
 * <code>startContainer</code>.
 *
 * @param startContainer//w  w w .  ja  va 2 s  . c o  m
 *            The GUI Element to start with.
 * @param enable
 *            <code>true</code>, if all elements will get enabled,
 *            <code>false</code> if all elements will get disabled.
 */
private void disOrEnableAllElements(Container startContainer, boolean enable) {
    Component[] children = startContainer.getComponents();
    for (Component child : children) {
        if (child instanceof Container) {
            disOrEnableAllElements((Container) child, enable);
        }
        child.setEnabled(enable);
    }
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ???????//from  w ww .j  a  va 2 s  . com
 * 
 * @param parent ?
 * @return ????
 */
protected Component[] getComponents(Container parent) {
    if (parent instanceof MenuElement) {
        MenuElement[] sub = ((MenuElement) parent).getSubElements();
        Component[] com = new Component[sub.length];
        for (int i = 0; i < sub.length; i++) {
            com[i] = sub[i].getComponent();
        }

        return com;
    } else {
        return parent.getComponents();
    }
}

From source file:fxts.stations.ui.SideLayout.java

/**
 * Fills in an instance of <code>SideLayoutInfo</code> for the
 * current set of managed children. This requires three passes through the
 * set of children://  ww  w.  j  a v  a  2s . c  o  m
 * <ol>
 * <li>Figure out the dimensions of the layout grid.
 * <li>Determine which cells the components occupy.
 * <li>Distribute the weights and min sizes amoung the rows/columns.
 * </ol>
 * This also caches the minsizes for all the children when they are
 * first encountered (so subsequent loops don't need to ask again).
 *
 * @param aParent   the layout container
 * @param aSizeflag either <code>PREFERREDSIZE</code> or <code>MINSIZE</code>
 *
 * @return the <code>SideLayoutInfo</code> for the set of children
 */
protected SideLayoutInfo getLayoutInfo(Container aParent, int aSizeflag) {
    synchronized (aParent.getTreeLock()) {
        SideLayoutInfo r = new SideLayoutInfo();
        Component comp;
        SideConstraints constraints;
        Dimension d;
        Component[] components = aParent.getComponents();
        int compindex;
        int i;
        int j;
        int k;
        int px;
        int py;
        int pixels_diff;
        int nextSize;
        int curX, curY, curWidth, curHeight, curRow, curCol;
        double weight_diff;
        double weight;
        double start;
        double size;
        int[] xMax;
        int[] yMax;

        /*
        * Pass #1
        *
        * Figure out the dimensions of the layout grid (use a value of 1 for
        * zero or negative widths and heights).
        */

        r.width = r.height = 0;
        curRow = curCol = -1;
        xMax = new int[MAXGRIDSIZE];
        yMax = new int[MAXGRIDSIZE];
        for (compindex = 0; compindex < components.length; compindex++) {
            comp = components[compindex];
            if (!comp.isVisible()) {
                continue;
            }
            constraints = lookupConstraints(comp);
            curX = constraints.gridx;
            curY = constraints.gridy;
            curWidth = constraints.gridwidth;
            if (curWidth <= 0) {
                curWidth = 1;
            }
            curHeight = constraints.gridheight;
            if (curHeight <= 0) {
                curHeight = 1;
            }

            /* If x or y is negative, then use relative positioning: */
            if (curX < 0 && curY < 0) {
                if (curRow >= 0) {
                    curY = curRow;
                } else if (curCol >= 0) {
                    curX = curCol;
                } else {
                    curY = 0;
                }
            }
            if (curX < 0) {
                px = 0;
                for (i = curY; i < curY + curHeight; i++) {
                    px = Math.max(px, xMax[i]);
                }
                curX = px - curX - 1;
                if (curX < 0) {
                    curX = 0;
                }
            } else if (curY < 0) {
                py = 0;
                for (i = curX; i < curX + curWidth; i++) {
                    py = Math.max(py, yMax[i]);
                }
                curY = py - curY - 1;
                if (curY < 0) {
                    curY = 0;
                }
            }

            /* Adjust the grid width and height */
            for (px = curX + curWidth; r.width < px; r.width++) {
            }
            for (py = curY + curHeight; r.height < py; r.height++) {
            }

            /* Adjust the xMax and yMax arrays */
            for (i = curX; i < curX + curWidth; i++) {
                yMax[i] = py;
            }
            for (i = curY; i < curY + curHeight; i++) {
                xMax[i] = px;
            }

            /* Cache the current slave's size. */
            if (aSizeflag == PREFERREDSIZE) {
                d = comp.getPreferredSize();
            } else {
                d = comp.getMinimumSize();
            }
            constraints.minWidth = d.width;
            //constraints.setMinWidth(d.width);
            constraints.minHeight = d.height;

            /* Zero width and height must mean that this is the last item (or
            * else something is wrong). */
            if (constraints.gridheight == 0 && constraints.gridwidth == 0) {
                curRow = curCol = -1;
            }

            /* Zero width starts a new row */
            if (constraints.gridheight == 0 && curRow < 0) {
                curCol = curX + curWidth;
            }

            /* Zero height starts a new column */
            else if (constraints.gridwidth == 0 && curCol < 0) {
                curRow = curY + curHeight;
            }
        }

        /*
        * Apply minimum row/column dimensions
        */
        if (mColumnWidths != null && r.width < mColumnWidths.length) {
            r.width = mColumnWidths.length;
        }
        if (mRowHeights != null && r.height < mRowHeights.length) {
            r.height = mRowHeights.length;
        }

        /*
        * Pass #2
        *
        * Negative values for gridX are filled in with the current x value.
        * Negative values for gridY are filled in with the current y value.
        * Negative or zero values for gridWidth and gridHeight end the current
        *  row or column, respectively.
        */

        curRow = curCol = -1;
        xMax = new int[MAXGRIDSIZE];
        yMax = new int[MAXGRIDSIZE];
        for (compindex = 0; compindex < components.length; compindex++) {
            comp = components[compindex];
            if (!comp.isVisible()) {
                continue;
            }
            constraints = lookupConstraints(comp);
            curX = constraints.gridx;
            curY = constraints.gridy;
            curWidth = constraints.gridwidth;
            curHeight = constraints.gridheight;

            /* If x or y is negative, then use relative positioning: */
            if (curX < 0 && curY < 0) {
                if (curRow >= 0) {
                    curY = curRow;
                } else if (curCol >= 0) {
                    curX = curCol;
                } else {
                    curY = 0;
                }
            }
            if (curX < 0) {
                if (curHeight <= 0) {
                    curHeight += r.height - curY;
                    if (curHeight < 1) {
                        curHeight = 1;
                    }
                }
                px = 0;
                for (i = curY; i < curY + curHeight; i++) {
                    px = Math.max(px, xMax[i]);
                }
                curX = px - curX - 1;
                if (curX < 0) {
                    curX = 0;
                }
            } else if (curY < 0) {
                if (curWidth <= 0) {
                    curWidth += r.width - curX;
                    if (curWidth < 1) {
                        curWidth = 1;
                    }
                }
                py = 0;
                for (i = curX; i < curX + curWidth; i++) {
                    py = Math.max(py, yMax[i]);
                }
                curY = py - curY - 1;
                if (curY < 0) {
                    curY = 0;
                }
            }
            if (curWidth <= 0) {
                curWidth += r.width - curX;
                if (curWidth < 1) {
                    curWidth = 1;
                }
            }
            if (curHeight <= 0) {
                curHeight += r.height - curY;
                if (curHeight < 1) {
                    curHeight = 1;
                }
            }
            px = curX + curWidth;
            py = curY + curHeight;
            for (i = curX; i < curX + curWidth; i++) {
                yMax[i] = py;
            }
            for (i = curY; i < curY + curHeight; i++) {
                xMax[i] = px;
            }

            /* Make negative sizes start a new row/column */
            if (constraints.gridheight == 0 && constraints.gridwidth == 0) {
                curRow = curCol = -1;
            }
            if (constraints.gridheight == 0 && curRow < 0) {
                curCol = curX + curWidth;
            } else if (constraints.gridwidth == 0 && curCol < 0) {
                curRow = curY + curHeight;
            }

            /* Assign the new values to the gridbag slave */
            constraints.tempX = curX;
            constraints.tempY = curY;
            constraints.tempWidth = curWidth;
            constraints.tempHeight = curHeight;
        }

        /*
        * Apply minimum row/column dimensions and weights
        */
        if (mColumnWidths != null) {
            System.arraycopy(mColumnWidths, 0, r.minWidth, 0, mColumnWidths.length);
        }
        if (mRowHeights != null) {
            System.arraycopy(mRowHeights, 0, r.minHeight, 0, mRowHeights.length);
        }
        if (mColumnWeights != null) {
            System.arraycopy(mColumnWeights, 0, r.weightX, 0, mColumnWeights.length);
        }
        if (mRowWeights != null) {
            System.arraycopy(mRowWeights, 0, r.weightY, 0, mRowWeights.length);
        }

        /*
        * Pass #3
        *
        * Distribute the minimun widths and weights:
        */

        nextSize = Integer.MAX_VALUE;
        for (i = 1; i != Integer.MAX_VALUE; i = nextSize, nextSize = Integer.MAX_VALUE) {
            for (compindex = 0; compindex < components.length; compindex++) {
                comp = components[compindex];
                if (!comp.isVisible()) {
                    continue;
                }
                constraints = lookupConstraints(comp);
                if (constraints.tempWidth == i) {
                    px = constraints.tempX + constraints.tempWidth; /* right column */

                    /*
                    * Figure out if we should use this slave\'s weight.  If the weight
                    * is less than the total weight spanned by the width of the cell,
                    * then discard the weight.  Otherwise split the difference
                    * according to the existing weights.
                    */

                    weight_diff = constraints.weightx;
                    for (k = constraints.tempX; k < px; k++) {
                        weight_diff -= r.weightX[k];
                    }
                    if (weight_diff > 0.0) {
                        weight = 0.0;
                        for (k = constraints.tempX; k < px; k++) {
                            weight += r.weightX[k];
                        }
                        for (k = constraints.tempX; weight > 0.0 && k < px; k++) {
                            double wt = r.weightX[k];
                            double dx = (wt * weight_diff) / weight;
                            r.weightX[k] += dx;
                            weight_diff -= dx;
                            weight -= wt;
                        }
                        /* Assign the remainder to the rightmost cell */
                        r.weightX[px - 1] += weight_diff;
                    }

                    /*
                    * Calculate the minWidth array values.
                    * First, figure out how wide the current slave needs to be.
                    * Then, see if it will fit within the current minWidth values.
                    * If it will not fit, add the difference according to the
                    * weightX array.
                    */

                    pixels_diff = constraints.minWidth + constraints.ipadx + constraints.insets.left
                            + constraints.insets.right;
                    for (k = constraints.tempX; k < px; k++) {
                        pixels_diff -= r.minWidth[k];
                    }
                    if (pixels_diff > 0) {
                        weight = 0.0;
                        for (k = constraints.tempX; k < px; k++) {
                            weight += r.weightX[k];
                        }
                        for (k = constraints.tempX; weight > 0.0 && k < px; k++) {
                            double wt = r.weightX[k];
                            int dx = (int) ((wt * (double) pixels_diff) / weight);
                            r.minWidth[k] += dx;
                            pixels_diff -= dx;
                            weight -= wt;
                        }
                        /* Any leftovers go into the rightmost cell */
                        r.minWidth[px - 1] += pixels_diff;
                    }
                } else if (constraints.tempWidth > i && constraints.tempWidth < nextSize) {
                    nextSize = constraints.tempWidth;
                }
                if (constraints.tempHeight == i) {
                    py = constraints.tempY + constraints.tempHeight; /* bottom row */

                    /*
                    * Figure out if we should use this slave's weight.  If the weight
                    * is less than the total weight spanned by the height of the cell,
                    * then discard the weight.  Otherwise split it the difference
                    * according to the existing weights.
                    */

                    weight_diff = constraints.weighty;
                    for (k = constraints.tempY; k < py; k++) {
                        weight_diff -= r.weightY[k];
                    }
                    if (weight_diff > 0.0) {
                        weight = 0.0;
                        for (k = constraints.tempY; k < py; k++) {
                            weight += r.weightY[k];
                        }
                        for (k = constraints.tempY; weight > 0.0 && k < py; k++) {
                            double wt = r.weightY[k];
                            double dy = (wt * weight_diff) / weight;
                            r.weightY[k] += dy;
                            weight_diff -= dy;
                            weight -= wt;
                        }
                        /* Assign the remainder to the bottom cell */
                        r.weightY[py - 1] += weight_diff;
                    }

                    /*
                    * Calculate the minHeight array values.
                    * First, figure out how tall the current slave needs to be.
                    * Then, see if it will fit within the current minHeight values.
                    * If it will not fit, add the difference according to the
                    * weightY array.
                    */

                    pixels_diff = constraints.minHeight + constraints.ipady + constraints.insets.top
                            + constraints.insets.bottom;
                    for (k = constraints.tempY; k < py; k++) {
                        pixels_diff -= r.minHeight[k];
                    }
                    if (pixels_diff > 0) {
                        weight = 0.0;
                        for (k = constraints.tempY; k < py; k++) {
                            weight += r.weightY[k];
                        }
                        for (k = constraints.tempY; weight > 0.0 && k < py; k++) {
                            double wt = r.weightY[k];
                            int dy = (int) ((wt * (double) pixels_diff) / weight);
                            r.minHeight[k] += dy;
                            pixels_diff -= dy;
                            weight -= wt;
                        }
                        /* Any leftovers go into the bottom cell */
                        r.minHeight[py - 1] += pixels_diff;
                    }
                } else if (constraints.tempHeight > i && constraints.tempHeight < nextSize) {
                    nextSize = constraints.tempHeight;
                }
            }
        }
        return r;
    }
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

/**
*//*  w  w  w .j a v a2s  . c  o  m*/
private void emptyContainer(Container container) {
    Component[] components = container.getComponents();

    if (components != null) {
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof Container) {
                emptyContainer((Container) components[i]);
            }
        }
    }

    components = null;
    container.removeAll();
    container = null;
}

From source file:ireport_5_6_0.view.JRViewer.java

/**
 *//*  w  w  w.  jav a  2s. com*/
private void emptyContainer(Container container) {
    Component[] components = container.getComponents();

    if (components != null) {
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof Container) {
                emptyContainer((Container) components[i]);
            }
        }
    }
    components = null;
    container.removeAll();
    container = null;
}

From source file:fxts.stations.ui.SideLayout.java

/**
 * Lays out the grid.//from   w  w  w . j  av  a 2  s  . c om
 *
 * @param aParent the layout container
 */
protected void arrangeGrid(Container aParent) {
    /////////////////////////////////////////////////////////
    //It`s only for debugging
    JComponent jc = (JComponent) aParent;
    String sType = (String) jc.getClientProperty("TYPE");
    if (sType != null) {
        boolean bInternal = "internal".equals(sType);
        mLogger.debug("\n" + sType);
    }
    //////////////////////////////////////////////////////////
    Component comp;
    int compindex;
    SideConstraints constraints;
    Insets insets = aParent.getInsets();
    Component[] components = aParent.getComponents();
    Dimension d;
    Rectangle r = new Rectangle();
    int i, diffw, diffh;
    double weight;
    SideLayoutInfo info;
    mRightToLeft = !aParent.getComponentOrientation().isLeftToRight();

    /*
    * If the parent has no slaves anymore, then don't do anything
    * at all:  just leave the parent's size as-is.
    */
    if (components.length == 0 && (mColumnWidths == null || mColumnWidths.length == 0)
            && (mRowHeights == null || mRowHeights.length == 0)) {
        return;
    }

    /*
    * Pass #1: scan all the slaves to figure out the total amount
    * of space needed.
    */

    info = getLayoutInfo(aParent, PREFERREDSIZE);
    d = getMinSize(aParent, info);

    //
    //    System.out.println("parent=w:" + parent.getWidth() + ",h:" + parent.getHeight() +
    //                       "min=w:" + d.getWidth() + ",h:" + d.getHeight());
    if (aParent.getWidth() < d.width || aParent.getHeight() < d.height) {
        info = getLayoutInfo(aParent, MINSIZE);
        d = getMinSize(aParent, info);
        //
        //      System.out.println("MINSIZE");
    } else {
        //
        //      System.out.println("Non MINSIZE");
    }
    mLayoutInfo = info;
    r.width = d.width;
    r.height = d.height;

    /*
    * If the current dimensions of the window don't match the desired
    * dimensions, then adjust the minWidth and minHeight arrays
    * according to the weights.
    */

    diffw = aParent.getWidth() - r.width;
    //
    //    System.out.println("diffw=" + diffw);
    if (diffw != 0) {
        weight = 0.0;
        for (i = 0; i < info.width; i++) {
            weight += info.weightX[i];
        }
        if (weight > 0.0) {
            for (i = 0; i < info.width; i++) {
                int dx = (int) (((double) diffw * info.weightX[i]) / weight);
                info.minWidth[i] += dx;
                r.width += dx;
                if (info.minWidth[i] < 0) {
                    r.width -= info.minWidth[i];
                    info.minWidth[i] = 0;
                }
            }
        }
        diffw = aParent.getWidth() - r.width;
    } else {
        diffw = 0;
    }
    diffh = aParent.getHeight() - r.height;
    //
    //    System.out.println("diffh=" + diffh);
    if (diffh != 0) {
        weight = 0.0;
        for (i = 0; i < info.height; i++) {
            weight += info.weightY[i];
        }
        if (weight > 0.0) {
            for (i = 0; i < info.height; i++) {
                int dy = (int) (((double) diffh * info.weightY[i]) / weight);
                info.minHeight[i] += dy;
                r.height += dy;
                if (info.minHeight[i] < 0) {
                    r.height -= info.minHeight[i];
                    info.minHeight[i] = 0;
                }
            }
        }
        diffh = aParent.getHeight() - r.height;
    } else {
        diffh = 0;
    }

    /*
    * Now do the actual layout of the slaves using the layout information
    * that has been collected.
    */

    info.startx = /*diffw/2 +*/ insets.left;
    info.starty = /*diffh/2 +*/ insets.top;
    //
    //    System.out.println("info.startx = " + info.startx);
    //    System.out.println("info.starty = " + info.startx);
    for (compindex = 0; compindex < components.length; compindex++) {
        comp = components[compindex];
        if (!comp.isVisible()) {
            continue;
        }
        constraints = lookupConstraints(comp);
        if (!mRightToLeft) {
            r.x = info.startx;
            for (i = 0; i < constraints.tempX; i++) {
                r.x += info.minWidth[i];
            }
        } else {
            r.x = aParent.getWidth() - insets.right;
            for (i = 0; i < constraints.tempX; i++) {
                r.x -= info.minWidth[i];
            }
        }
        r.y = info.starty;
        for (i = 0; i < constraints.tempY; i++) {
            r.y += info.minHeight[i];
        }
        r.width = 0;
        for (i = constraints.tempX; i < constraints.tempX + constraints.tempWidth; i++) {
            r.width += info.minWidth[i];
        }
        r.height = 0;
        for (i = constraints.tempY; i < constraints.tempY + constraints.tempHeight; i++) {
            r.height += info.minHeight[i];
        }
        adjustForGravity(constraints, r);
        if (r.x < 0) {
            r.width -= r.x;
            r.x = 0;
        }
        if (r.y < 0) {
            r.height -= r.y;
            r.y = 0;
        }

        /*
        * If the window is too small to be interesting then
        * unmap it.  Otherwise configure it and then make sure
        * it's mapped.
        */

        if (r.width <= 0 || r.height <= 0) {
            comp.setBounds(0, 0, 0, 0);
        } else {
            if (comp.getX() != r.x || comp.getY() != r.y || comp.getWidth() != r.width
                    || comp.getHeight() != r.height) {
                comp.setBounds(r.x, r.y, r.width, r.height);
            }
        }

        //        System.out.println("Initial component size (x = " + (int)comp.getX() +
        //                           ", y = " + (int)(comp.getY()) +
        //                           ", widht = " + (int)(comp.getWidth()) +
        //                           ", height = " + (int)(comp.getHeight()));
        if (diffw > 0) {
            //            System.out.println("It`s increasing by x!");
            //if (comp instanceof IResizableComponent) {
            //                System.out.println("It`s resizable component: " + comp);

            //IResizableComponent resizeComp = (IResizableComponent)comp;
            ResizeParameter param = constraints.resize;

            //                System.out.println("Params: Left=" + param.getLeft() + ",top=" + param.getTop() +
            //                                   ",Right=" + param.getRight() + ",bottom=" + param.getBottom());
            comp.setBounds((int) (comp.getX() + diffw * param.getLeft()), comp.getY(),
                    (int) (comp.getWidth() + diffw * (param.getRight() - param.getLeft())), comp.getHeight());

            //                System.out.println("Set Bounds (x = " + (int)(comp.getX() + diffw * param.getLeft()) +
            //                    ", y = " + (int)(comp.getY()) +
            //                    ", widht = " + (int)(comp.getWidth() +
            ///                                     diffw * (param.getRight() - param.getLeft())) +
            //                    ", height = " + (int)(comp.getHeight()));
            //            }
        }
        if (diffh > 0) {
            //            System.out.println("It`s increasing by y!");
            //            if (comp instanceof IResizableComponent) {
            //                System.out.println("It`s resizable component: " + comp);

            //                IResizableComponent resizeComp = (IResizableComponent)comp;
            ResizeParameter param = constraints.resize;

            //                System.out.println("Params: Left=" + param.getLeft() + ",top=" + param.getTop() +
            //                                   ",Right=" + param.getRight() + ",bottom=" + param.getBottom());
            comp.setBounds(comp.getX(), (int) (comp.getY() + diffh * param.getTop()), comp.getWidth(),
                    (int) (comp.getHeight() + diffh * (param.getBottom() - param.getTop())));

            //                System.out.println("Set Bounds (x = " + (int)(comp.getX()) +
            //                    ", y = " + (int)(comp.getY() + diffh * param.getTop()) +
            //                    ", widht = " + (int)(comp.getWidth()) +
            //                    ", height = " + (int)(comp.getHeight() +
            //                                     diffh * (param.getBottom() - param.getTop())));
            //            }
        }
    }
}