Example usage for java.awt Container getInsets

List of usage examples for java.awt Container getInsets

Introduction

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

Prototype

public Insets getInsets() 

Source Link

Document

Determines the insets of this container, which indicate the size of the container's border.

Usage

From source file:org.kineticsystem.commons.layout.TetrisLayout.java

/** 
 * Return the minimum size of this container.
 * @param parent The container to be laid out.
 * @return The minimum container size dimension.
 *//* ww  w  . jav  a  2s .c  om*/
public Dimension minimumLayoutSize(Container parent) {

    if (containerSize == null) {
        setup(parent);
    }

    Insets insets = parent.getInsets();
    double minWidth = minGapFreeWidth + insets.left + insets.right + cGaps[cBars.length].getIncSize();
    double minHeight = minGapFreeHeight + insets.top + insets.bottom + rGaps[rBars.length].getIncSize();

    // Return minimal container size.

    Dimension d = new Dimension((int) Math.round(minWidth), (int) Math.round(minHeight));
    return d;
}

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

/**
 * Figures out the minimum size of the//from w ww.j av a 2  s  . c  o  m
 * master based on the information from getLayoutInfo().
 *
 * @param aParent the layout container
 * @param aInfo   the layout info for this parent
 *
 * @return a <code>Dimension</code> object containing the
 *         minimum size
 */
protected Dimension getMinSize(Container aParent, SideLayoutInfo aInfo) {
    Dimension d = new Dimension();
    int i, t;
    Insets insets = aParent.getInsets();
    t = 0;
    for (i = 0; i < aInfo.width; i++) {
        t += aInfo.minWidth[i];
    }
    d.width = t + insets.left + insets.right;
    t = 0;
    for (i = 0; i < aInfo.height; i++) {
        t += aInfo.minHeight[i];
    }
    d.height = t + insets.top + insets.bottom;
    return d;
}

From source file:org.kineticsystem.commons.layout.TetrisLayout.java

/**
 * Calculate the preferred size dimensions for the specified panel given
 * the components in the specified parent container. Calculates incremental
 * column width rates and row heights, dimensions used during component
 * laying out. /*from w ww .  j av a2 s .com*/
 * @param parent The component to be laid out.
 */
private void setup(Container parent) {

    container = parent;
    Insets insets = parent.getInsets();

    // FIRST PHASE: DEFAULT EVALUATION OF COLUMN AND ROW SIZES.

    // Evaluate column widths.

    for (int c = 0; c < cBars.length; c++) {
        if (cBars[c].getSize() == Bar.COMPONENT_PREFERRED_SIZE) {
            for (int r = 0; r < rBars.length; r++) {
                Component comp = componentAt(r, c);
                Cell cell = (Cell) constraintsMap.get(comp);
                if (comp.isVisible() && ((cell.getCols() + cell.getCol() - 1) == c)) {
                    Size cd = (Size) componentSizes.get(comp);
                    cBars[c].setPreferredSize(Math.max(cd.getPreferredWidth(), cBars[c].getPreferredSize()));
                    cBars[c].setMinimumSize(Math.max(cd.getMinimumWidth(), cBars[c].getMinimumSize()));
                    cBars[c].setMaximumSize(Double.MAX_VALUE);
                }
            }
        } else {
            cBars[c].setPreferredSize(cBars[c].getSize());
        }

        // Check all components containing column c and store their sizes.

        for (Map.Entry<Component, Cell> entry : constraintsMap.entrySet()) {

            Component comp = (Component) entry.getKey();
            Cell cell = (Cell) entry.getValue();
            if (((cell.getCol() + cell.getCols()) >= c) && (cell.getCol() <= c)) {
                Size d = (Size) componentSizes.get(comp);
                d.setPreferredWidth(d.getPreferredWidth() - cBars[c].getPreferredSize());
                d.setMinimumWidth(d.getMinimumWidth() - cBars[c].getMinimumSize());
            }
        }
    }

    // Evaluate row heights.

    for (int r = 0; r < rBars.length; r++) {
        if (rBars[r].getSize() == Bar.COMPONENT_PREFERRED_SIZE) {
            for (int c = 0; c < cBars.length; c++) {
                Component comp = componentAt(r, c);
                Cell cell = (Cell) constraintsMap.get(comp);
                if (comp.isVisible() && ((cell.getRows() + cell.getRow() - 1) == r)) {
                    Size cd = (Size) componentSizes.get(comp);
                    rBars[r].setPreferredSize(Math.max(cd.getPreferredHeight(), rBars[r].getPreferredSize()));
                    rBars[r].setMinimumSize(Math.max(cd.getMinimumHeight(), rBars[r].getMinimumSize()));
                    rBars[r].setMaximumSize(Double.MAX_VALUE);
                }
            }
        } else {
            rBars[r].setWeight(rBars[r].getSize());
        }

        // Check all components containing row r and store their sizes.

        for (Map.Entry<Component, Cell> entry : constraintsMap.entrySet()) {

            Component comp = (Component) entry.getKey();
            Cell cell = (Cell) entry.getValue();
            if (((cell.getRow() + cell.getRows()) >= r) && (cell.getRow() <= r)) {
                Size d = (Size) componentSizes.get(comp);
                d.setPreferredHeight(d.getPreferredHeight() - rBars[r].getPreferredSize());
                d.setMinimumHeight(d.getMinimumHeight() - rBars[r].getMinimumSize());
            }
        }
    }

    // SECOND PHASE: OVERRIDE DEFAULT EVALUATION OF COLUMN AND ROW SIZES.

    /*
     * Override previous evaluation of column and row sizes using
     * connectors.
     */

    initBarConnectors(cBars, cGaps);
    initBarConnectors(rBars, rGaps);

    // Evaluates container widths and heights.

    for (int i = 0; i < cBars.length; i++) {
        minGapFreeWidth += cBars[i].getMinimumSize();
        maxGapFreeWidth += cBars[i].getMaximumSize();
        preferredGapFreeWidth += cBars[i].getPreferredSize();
    }
    for (int i = 0; i < rBars.length; i++) {
        minGapFreeHeight += rBars[i].getMinimumSize();
        maxGapFreeHeight += rBars[i].getMaximumSize();
        preferredGapFreeHeight += rBars[i].getPreferredSize();
    }

    // Adds insets and gaps.

    initGaps(cGaps);
    initGaps(rGaps);

    double preferredWidth = preferredGapFreeWidth + insets.left + insets.right
            + cGaps[cBars.length].getIncSize();
    double preferredHeight = preferredGapFreeHeight + insets.top + insets.bottom
            + rGaps[rBars.length].getIncSize();

    // Sets preferred container size.

    containerSize = new Dimension((int) Math.round(preferredWidth), (int) Math.round(preferredHeight));

    // THIRD PHASE: EVALUATE ROW AND COLUMN SIZE FUNCTIONS.

    initSizes(cSizes, cBars, preferredGapFreeWidth);
    initSizes(rSizes, rBars, preferredGapFreeHeight);
}

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

/**
 * Lays out the grid.//from  ww  w .j a  v  a2  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())));
            //            }
        }
    }
}

From source file:org.kineticsystem.commons.layout.TetrisLayout.java

/**
 * Lay out components in the specified container.
 * @param parent The container which needs to be laid out.
 *///from  ww w .j  a  v  a 2 s  .co  m
public void layoutContainer(Container parent) {

    /* 
     * This method synchronizes on the tree lock of the component. This tree
     * lock is an object that can be used to provide thread-safe access to
     * the layout manager in case different threads are simultaneously
     * adding or removing components. The tree lock object is used as a
     * synchronization point for all of the methods associated with laying
     * out containers and invalidating components, and it is good
     * programming practice to use it to ensure a thread-safe
     * implementation.
     */

    synchronized (parent.getTreeLock()) {

        // Layout components.

        if (containerSize == null) {
            setup(parent);
        }

        Insets insets = parent.getInsets();

        int componentNumber = parent.getComponentCount();
        if (componentNumber == 0) {
            return;
        }

        Dimension size = parent.getSize();

        cGaps[0].setIncSize(cGaps[0].getSize());
        for (int i = 1; i < cBars.length + 1; i++) {
            cGaps[i].setIncSize(cGaps[i].getSize() + cGaps[i - 1].getIncSize());
        }
        rGaps[0].setIncSize(rGaps[0].getSize());
        for (int i = 1; i < rBars.length + 1; i++) {
            rGaps[i].setIncSize(rGaps[i].getSize() + rGaps[i - 1].getIncSize());
        }

        int actualGapFreeWidth = Math
                .max(size.width - insets.left - insets.right - cGaps[cBars.length].getIncSize(), 0);
        int actualGapFreeHeight = Math
                .max(size.height - insets.top - insets.bottom - rGaps[rBars.length].getIncSize(), 0);

        for (Map.Entry<Component, Cell> entry : constraintsMap.entrySet()) {

            Component comp = (Component) entry.getKey();
            Cell cell = (Cell) entry.getValue();
            if (cell != null) {

                // Actual cell position.

                int x0 = (int) Math.round(cSizes[cell.getCol()].evaluate(actualGapFreeWidth));
                int y0 = (int) Math.round(rSizes[cell.getRow()].evaluate(actualGapFreeHeight));
                int x1 = (int) Math.round(cSizes[cell.getCol() + cell.getCols()].evaluate(actualGapFreeWidth));
                int y1 = (int) Math.round(rSizes[cell.getRow() + cell.getRows()].evaluate(actualGapFreeHeight));

                // Actual cell dimension.

                int w = x1 - x0;
                int h = y1 - y0;

                // Component position correction.

                int xCorrection = insets.left + cGaps[cell.getCol()].getIncSize();
                int yCorrection = insets.top + rGaps[cell.getRow()].getIncSize();

                // Component dimension correction.

                int wCorrection = cGaps[cell.getCol() + cell.getCols() - 1].getIncSize()
                        - cGaps[cell.getCol()].getIncSize();
                int hCorrection = rGaps[cell.getRow() + cell.getRows() - 1].getIncSize()
                        - rGaps[cell.getRow()].getIncSize();

                // Preferred component dimension.

                int wComp = comp.getPreferredSize().width;
                int hComp = comp.getPreferredSize().height;

                int fill = cell.getFill();
                int anchor = cell.getAnchor();

                switch (fill) {
                case Cell.NONE: {
                    if (wComp > w) {
                        wComp = w;
                    }
                    if (hComp > h) {
                        hComp = h;
                    }
                    switch (anchor) {
                    case Cell.FIRST_LINE_START:
                        x0 += xCorrection;
                        y0 += yCorrection;
                        break;
                    case Cell.PAGE_START:
                        x0 += xCorrection + (w - wComp) / 2;
                        y0 += yCorrection;
                        break;
                    case Cell.FIRST_LINE_END:
                        x0 += xCorrection + w + wCorrection - wComp;
                        y0 += yCorrection;
                        break;
                    case Cell.LINE_START:
                        x0 += xCorrection;
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.CENTER:
                        x0 += xCorrection + (w - wComp) / 2;
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.LINE_END:
                        x0 += xCorrection + w + wCorrection - wComp;
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.LAST_LINE_START:
                        x0 += xCorrection;
                        y0 += yCorrection + h + hCorrection - hComp;
                        break;
                    case Cell.PAGE_END:
                        x0 += xCorrection + (w - wComp) / 2;
                        y0 += yCorrection + h + hCorrection - hComp;
                        break;
                    case Cell.LAST_LINE_END:
                        x0 += xCorrection + w + wCorrection - wComp;
                        y0 += yCorrection + h - hCorrection - hComp;
                        break;
                    }
                    w = Math.min(w, wComp) + wCorrection;
                    h = Math.min(h, hComp) + hCorrection;
                    break;
                }
                case Cell.PROPORTIONAL: {
                    double ratio = Math.min((double) ((double) w / (double) wComp),
                            (double) ((double) h / (double) hComp));
                    wComp = (int) Math.round(wComp * ratio);
                    hComp = (int) Math.round(hComp * ratio);
                    switch (anchor) {
                    case Cell.FIRST_LINE_START:
                        x0 += xCorrection;
                        y0 += yCorrection;
                        break;
                    case Cell.PAGE_START:
                        x0 += xCorrection + (w - wComp) / 2;
                        y0 += yCorrection;
                        break;
                    case Cell.FIRST_LINE_END:
                        x0 += xCorrection + wCorrection + w - wComp;
                        y0 += yCorrection;
                        break;
                    case Cell.LINE_START:
                        x0 += xCorrection;
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.CENTER:
                        x0 += xCorrection + (w - wComp) / 2;
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.LINE_END:
                        x0 += xCorrection + wCorrection + w - wComp;
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.LAST_LINE_START:
                        x0 += xCorrection;
                        y0 += yCorrection + hCorrection + h - hComp;
                        break;
                    case Cell.PAGE_END:
                        x0 += xCorrection + (w - wComp) / 2;
                        y0 += yCorrection + hCorrection + h - hComp;
                        break;
                    case Cell.LAST_LINE_END:
                        x0 += xCorrection + wCorrection + w - wComp;
                        y0 += yCorrection + hCorrection + h - hComp;
                        break;
                    }
                    w = Math.min(w, wComp) + wCorrection;
                    h = Math.min(h, hComp) + hCorrection;
                    break;
                }
                case Cell.BOTH: {
                    x0 += xCorrection;
                    y0 += yCorrection;
                    w += wCorrection;
                    h += hCorrection;
                    break;
                }
                case Cell.HORIZONTAL: {
                    if (hComp > h) {
                        hComp = h;
                    }
                    switch (anchor) {
                    case Cell.FIRST_LINE_START:
                    case Cell.PAGE_START:
                    case Cell.FIRST_LINE_END:
                        y0 += yCorrection;
                        break;
                    case Cell.LINE_START:
                    case Cell.CENTER:
                    case Cell.LINE_END:
                        y0 += yCorrection + (h - hComp) / 2;
                        break;
                    case Cell.LAST_LINE_START:
                    case Cell.PAGE_END:
                    case Cell.LAST_LINE_END:
                        y0 += yCorrection + h + hCorrection - hComp;
                        break;
                    }
                    x0 += xCorrection;
                    w += wCorrection;
                    h = Math.min(h, hComp) + hCorrection;
                    break;
                }
                case Cell.VERTICAL: {
                    if (wComp > w) {
                        wComp = w;
                    }
                    switch (anchor) {
                    case Cell.FIRST_LINE_START:
                    case Cell.LINE_START:
                    case Cell.LAST_LINE_START:
                        x0 += xCorrection;
                        break;
                    case Cell.PAGE_START:
                    case Cell.CENTER:
                    case Cell.PAGE_END:
                        x0 += xCorrection + (w - wComp) / 2;
                        break;
                    case Cell.FIRST_LINE_END:
                    case Cell.LINE_END:
                    case Cell.LAST_LINE_END:
                        x0 += xCorrection + w + wCorrection - wComp;
                        break;
                    }
                    y0 += yCorrection;
                    w = Math.min(w, wComp) + wCorrection;
                    h += hCorrection;
                    break;
                }
                }
                comp.setBounds(x0, y0, w, h);
            }
        }
    }
}

From source file:net.openbyte.gui.CreateProjectFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Gary Lee
    button1 = new JButton();
    textField1 = new JTextField();
    label1 = new JLabel();
    comboBox1 = new JComboBox<>();
    label2 = new JLabel();
    comboBox2 = new JComboBox<>();
    label3 = new JLabel();
    button2 = new JButton();

    //======== this ========
    setTitle("Project Creation");
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setResizable(false);//from  w  w w .j a v  a 2  s  .co m
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    //---- button1 ----
    button1.setText("Create project");
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button1ActionPerformed(e);
        }
    });
    contentPane.add(button1);
    button1.setBounds(new Rectangle(new Point(340, 170), button1.getPreferredSize()));
    contentPane.add(textField1);
    textField1.setBounds(10, 25, 245, textField1.getPreferredSize().height);

    //---- label1 ----
    label1.setText("Project Name");
    contentPane.add(label1);
    label1.setBounds(new Rectangle(new Point(10, 5), label1.getPreferredSize()));

    //---- comboBox1 ----
    comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { "Minecraft Forge", "MCP", "Bukkit" }));
    comboBox1.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            comboBox1ItemStateChanged(e);
        }
    });
    contentPane.add(comboBox1);
    comboBox1.setBounds(10, 70, 245, comboBox1.getPreferredSize().height);

    //---- label2 ----
    label2.setText("Modification API");
    contentPane.add(label2);
    label2.setBounds(new Rectangle(new Point(10, 50), label2.getPreferredSize()));

    //---- comboBox2 ----
    comboBox2.setModel(new DefaultComboBoxModel<>(new String[] { "1.8.9", "1.7.10" }));
    contentPane.add(comboBox2);
    comboBox2.setBounds(10, 120, 245, comboBox2.getPreferredSize().height);

    //---- label3 ----
    label3.setText("Minecraft Version");
    contentPane.add(label3);
    label3.setBounds(new Rectangle(new Point(10, 100), label3.getPreferredSize()));

    //---- button2 ----
    button2.setText("Cancel");
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button2ActionPerformed(e);
        }
    });
    contentPane.add(button2);
    button2.setBounds(new Rectangle(new Point(10, 170), button2.getPreferredSize()));

    { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
            Rectangle bounds = contentPane.getComponent(i).getBounds();
            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
    }
    setSize(480, 240);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:net.openbyte.gui.WelcomeFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Gary Lee
    scrollPane1 = new JScrollPane();
    list1 = new JList();
    button1 = new JButton();
    label2 = new JLabel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    button5 = new JButton();
    scrollPane2 = new JScrollPane();
    xImagePanel1 = new JXImagePanel();
    button6 = new JButton();
    button7 = new JButton();
    button8 = new JButton();

    //======== this ========
    setTitle("Welcome to OpenByte");
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setResizable(false);/*from w  ww .  j a  v  a 2  s  .  c o  m*/
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    //======== scrollPane1 ========
    {
        scrollPane1.setBorder(new TitledBorder(LineBorder.createGrayLineBorder(), "Recent Projects"));

        //---- list1 ----
        list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list1.setBackground(new Color(240, 240, 240));
        list1.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                list1ValueChanged(e);
            }
        });
        scrollPane1.setViewportView(list1);
    }
    contentPane.add(scrollPane1);
    scrollPane1.setBounds(15, 10, 165, 340);

    //---- button1 ----
    button1.setText("Open Project");
    button1.setEnabled(false);
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button1ActionPerformed(e);
        }
    });
    contentPane.add(button1);
    button1.setBounds(105, 355, 110, button1.getPreferredSize().height);

    //---- label2 ----
    label2.setText("Media");
    contentPane.add(label2);
    label2.setBounds(new Rectangle(new Point(605, 210), label2.getPreferredSize()));

    //---- button2 ----
    button2.setText("Minecraft Forums");
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button2ActionPerformed(e);
        }
    });
    contentPane.add(button2);
    button2.setBounds(500, 230, 151, button2.getPreferredSize().height);

    //---- button3 ----
    button3.setText("GitHub");
    button3.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button3ActionPerformed(e);
        }
    });
    contentPane.add(button3);
    button3.setBounds(500, 260, 150, button3.getPreferredSize().height);

    //---- button4 ----
    button4.setText("+");
    button4.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button4ActionPerformed(e);
        }
    });
    contentPane.add(button4);
    button4.setBounds(15, 355, 45, button4.getPreferredSize().height);

    //---- button5 ----
    button5.setText("-");
    button5.setEnabled(false);
    button5.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button5ActionPerformed(e);
        }
    });
    contentPane.add(button5);
    button5.setBounds(60, 355, 40, button5.getPreferredSize().height);

    //======== scrollPane2 ========
    {
        scrollPane2.setBorder(null);
        scrollPane2.setViewportView(xImagePanel1);
    }
    contentPane.add(scrollPane2);
    scrollPane2.setBounds(210, 25, 445, 160);

    //---- button6 ----
    button6.setText("Preferences");
    button6.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button6ActionPerformed(e);
        }
    });
    contentPane.add(button6);
    button6.setBounds(500, 290, 150, 30);

    //---- button7 ----
    button7.setText("About");
    button7.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button7ActionPerformed(e);
        }
    });
    contentPane.add(button7);
    button7.setBounds(500, 320, 150, 30);

    //---- button8 ----
    button8.setText("Plugins");
    button8.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button8ActionPerformed(e);
        }
    });
    contentPane.add(button8);
    button8.setBounds(500, 350, 150, 30);

    { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
            Rectangle bounds = contentPane.getComponent(i).getBounds();
            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
    }
    setSize(675, 425);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:main.java.gui.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - BOHDAN Korinnyi
    test = new JFrame();
    label1 = new JLabel();
    textField1 = new JTextField();
    label2 = new JLabel();
    textField2 = new JTextField();
    label3 = new JLabel();
    label4 = new JLabel();
    textField3 = new JTextField();
    textField4 = new JTextField();
    button1 = new JButton();
    button2 = new JButton();
    label5 = new JLabel();
    label6 = new JLabel();

    //======== test ========
    {/*  w w  w. j a v  a  2s  . c  o m*/
        test.setTitle("Pay mobile account");
        Container testContentPane = test.getContentPane();
        testContentPane.setLayout(null);

        //---- label1 ----
        label1.setText("\u0421\u0443\u043c\u0430");
        label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 4f));
        testContentPane.add(label1);
        label1.setBounds(new Rectangle(new Point(35, 30), label1.getPreferredSize()));

        //---- textField1 ----
        textField1.setColumns(10);
        testContentPane.add(textField1);
        textField1.setBounds(150, 30, 105, textField1.getPreferredSize().height);

        //---- label2 ----
        label2.setText("\u041d\u043e\u043c\u0435\u0440");
        label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 4f));
        testContentPane.add(label2);
        label2.setBounds(new Rectangle(new Point(35, 60), label2.getPreferredSize()));

        //---- textField2 ----
        textField2.setText("0674060606");
        textField2.setFont(textField2.getFont().deriveFont(textField2.getFont().getSize() + 2f));
        testContentPane.add(textField2);
        textField2.setBounds(150, 60, 105, textField2.getPreferredSize().height);

        //---- label3 ----
        label3.setText("\u041b\u043e\u0433\u0456\u043d");
        label3.setFont(label3.getFont().deriveFont(label3.getFont().getSize() + 4f));
        testContentPane.add(label3);
        label3.setBounds(new Rectangle(new Point(35, 95), label3.getPreferredSize()));

        //---- label4 ----
        label4.setText("\u041f\u0430\u0440\u043e\u043b\u044c");
        label4.setFont(label4.getFont().deriveFont(label4.getFont().getSize() + 4f));
        testContentPane.add(label4);
        label4.setBounds(new Rectangle(new Point(35, 125), label4.getPreferredSize()));
        testContentPane.add(textField3);
        textField3.setBounds(150, 95, 105, textField3.getPreferredSize().height);
        testContentPane.add(textField4);
        textField4.setBounds(150, 125, 105, 20);

        //---- button1 ----
        button1.setText("\u041e\u043f\u043b\u0430\u0442\u0438\u0442\u0438");
        button1.setFont(button1.getFont().deriveFont(button1.getFont().getStyle() | Font.BOLD,
                button1.getFont().getSize() + 2f));
        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String strTemp = textField1.getText();
                int cash = Integer.parseInt(strTemp);
                if (cash < 1) {
                    JOptionPane.showMessageDialog(null, "    '", "",
                            JOptionPane.OK_OPTION);
                    textField1.setText("0");
                } else if (textField3.getText().equals("test4") && textField4.getText().equals("12345")) {
                    check c = new check();
                    pay p = new pay();
                    getstatus g = new getstatus();
                    try {
                        c.connection(c.PaymentCollectionRequest("38" + getNumber(), getMoney()));
                        g.connection(c.PaymentStatusRequest());
                        p.connection(c.PaymentCollectionRequest("38" + getNumber(), getMoney()));
                        g.connection(c.PaymentStatusRequest());
                        information i = new information();
                        daoImplements h = new daoImplements();
                        long curTime = System.currentTimeMillis();
                        String curStringDate = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(curTime);

                        i.setIdTransaction(getTransaction.setGetTransaction());
                        i.setData(curStringDate);
                        i.setNumber(Integer.parseInt(getNumber()));
                        i.setSuma(Integer.parseInt(getMoney()));
                        i.setStatus(parserStatus.getStatusParsing());
                        h.addInfo(i);

                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (ParseException e2) {
                        // TODO Auto-generated catch block
                        e2.printStackTrace();
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "    ", "",
                            JOptionPane.OK_OPTION);
                    System.exit(0);
                }
            }

        });
        testContentPane.add(button1);
        button1.setBounds(150, 155, 115, 25);

        //---- button2 ----
        button2.setText("\u0406\u0441\u0442\u043e\u0440\u0456\u044f");
        button2.setFont(button2.getFont().deriveFont(button2.getFont().getStyle() | Font.BOLD,
                button2.getFont().getSize() + 2f));
        button2.setActionCommand("\u0406\u0441\u0442\u043e\u0440\u0456\u044f");
        button2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tableData t = new tableData();
            }
        });
        testContentPane.add(button2);
        button2.setBounds(15, 155, 115, 25);

        //---- label5 ----
        label5.setText(
                "\u0422\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0441\u0435\u0440\u0432\u0456\u0441 \u043f\u043e\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043c\u043e\u0431\u0456\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0445\u0443\u043d\u043a\u0443");
        label5.setFont(label5.getFont().deriveFont(label5.getFont().getStyle() & ~Font.ITALIC));
        testContentPane.add(label5);
        label5.setBounds(15, 0, 255, 20);

        //---- label6 ----
        label6.setText("38");
        label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() + 4f));
        testContentPane.add(label6);
        label6.setBounds(new Rectangle(new Point(130, 60), label6.getPreferredSize()));

        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for (int i = 0; i < testContentPane.getComponentCount(); i++) {
                Rectangle bounds = testContentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = testContentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            testContentPane.setMinimumSize(preferredSize);
            testContentPane.setPreferredSize(preferredSize);
        }
        test.pack();
        test.setLocationRelativeTo(test.getOwner());
    }
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}