Java tutorial
//package com.java2s; import java.awt.Component; import java.awt.Container; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; public class Main { public static void addGridBagComponent(Container container, GridBagLayout gridbag, GridBagConstraints c, Component com, int gridx, int gridy, int gridwidth, int gridheight) { c.gridx = gridx; c.gridy = gridy; c.gridwidth = gridwidth; c.gridheight = gridheight; gridbag.setConstraints(com, c); container.add(com); } }