set Grid Bag Constraints - Java Swing

Java examples for Swing:GridBagLayout

Description

set Grid Bag Constraints

Demo Code


//package com.java2s;
import java.awt.GridBagConstraints;
import java.awt.Insets;

public class Main {
    public static GridBagConstraints setGridBagConstraints(int x, int y,
            int width, int height, double weightx, double weighty) {
        GridBagConstraints constraits = new GridBagConstraints();

        constraits.gridx = x;/*  w w w  .  ja v  a  2  s  .  c om*/
        constraits.gridy = y;
        constraits.gridwidth = width;
        constraits.gridheight = height;
        constraits.weightx = weightx;
        constraits.weighty = weighty;
        constraits.insets = new Insets(0, 0, 0, 0);
        constraits.fill = GridBagConstraints.NONE;
        constraits.anchor = GridBagConstraints.CENTER;

        return constraits;
    }
}

Related Tutorials