Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (c) 2006 Thomas Weise
 * Software Foundation Classes
 * http://sourceforge.net/projects/java-sfc
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2007-02-23
 * Creator          : Thomas Weise
 * Original Filename: org.sfc.gui.ComponentUtils.java
 * Last modification: 2007-02-23
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to theFree Software
 *                    Foundation, Inc. 51 Franklin Street, Fifth Floor,
 *                    Boston, MA 02110-1301, USA or download the license
 *                    under http://www.gnu.org/licenses/lgpl.html or
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.LayoutManager;

public class Main {
    /** The default padding x */
    private static final int DEFAULT_IPAD_X = 1;
    /** The default padding y */
    private static final int DEFAULT_IPAD_Y = 1;

    /**
     * Puts the grid constraints for a component.
     * 
     * @param container
     *          The container to add the component to.
     * @param component
     *          The component to create the constraints for.
     * @param gridX
     *          The initial gridx value.
     * @param gridY
     *          The initial gridy value.
     * @param gridWidth
     *          The initial gridwidth value.
     * @param gridHeight
     *          The initial gridheight value.
     * @param weightX
     *          The initial weightx value.
     * @param weightY
     *          The initial weighty value.
     * @param anchor
     *          The initial anchor value.
     * @param fill
     *          The initial fill value.
     * @param insets
     *          The insets to be used.
     */
    public static final void insetPutGrid(final Container container, final Component component, final int gridX,
            final int gridY, final int gridWidth, final int gridHeight, final double weightX, final double weightY,
            final int anchor, final int fill, final Insets insets) {
        LayoutManager l;
        l = container.getLayout();
        if (l instanceof GridBagLayout) {
            ((GridBagLayout) (l)).setConstraints(component, new GridBagConstraints(gridX, gridY, gridWidth,
                    gridHeight, weightX, weightY, anchor, fill, insets, DEFAULT_IPAD_X, DEFAULT_IPAD_Y));
        }
        container.add(component);
    }
}