create Wide Grid Bag Constraints - Java Swing

Java examples for Swing:GridBagLayout

Description

create Wide Grid Bag Constraints

Demo Code


//package com.java2s;
import java.awt.*;

public class Main {
    public static final int DEFAULT_INSET = 1;

    public static GridBagConstraints createWideGridBagConstraints(
            int gridX, int gridY, int gridWidth, int leftInset,
            int rightInset) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.BOTH;
        gbc.weightx = 1;/*from  w  ww  .ja v  a2s  .c  o  m*/
        gbc.weighty = 1;
        gbc.gridx = gridX;
        gbc.gridy = gridY;
        gbc.gridwidth = gridWidth;

        gbc.insets = new Insets(DEFAULT_INSET, leftInset, DEFAULT_INSET,
                rightInset);

        return gbc;
    }
}

Related Tutorials